Apache bench (ab) for simple Load Testing

Apache bench (ab) is a simple tool to test load on your server or to check the time taken to server your website. Most of you already might have this tool installed by default. If you don’t have this tool, you can install the same as follows:

Install httpd-tools using yum:

[root@nagios ~]# yum install httpd-tools

You can check where the binary for ab is located as follows:

[root@nagios ~]# whereis ab

In case if you want to check which package should be installed to get this tool, you can try this command:

[root@nagios ~]# rpm -q –whatprovides /usr/bin/ab

To see all the options associated with ab, type as follows:

[root@nagios ~]# ab

If you want to see how fast Google can handle 100 requests, with a maximum of 10 requests running concurrently:

[root@nagios ~]# ab -n 100 -c 10 http://www.google.com/

Output is as follows:

This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.google.com (be patient).....done

Server Software:        gws
Server Hostname:        www.google.com
Server Port:            80

Document Path:          /
Document Length:        12518 bytes

Concurrency Level:      10
Time taken for tests:   0.453 seconds
Complete requests:      100
Failed requests:        98
   (Connect: 0, Receive: 0, Length: 98, Exceptions: 0)
Write errors:           0
Total transferred:      1462480 bytes
HTML transferred:       1257248 bytes
Requests per second:    220.77 [#/sec] (mean)
Time per request:       45.296 [ms] (mean)
Time per request:       4.530 [ms] (mean, across all concurrent requests)
Transfer rate:          3153.02 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       14   14   0.6     14      18
Processing:    25   29   5.1     27      45
Waiting:       24   26   1.6     25      34
Total:         39   44   5.2     42      59

Percentage of the requests served within a certain time (ms)
  50%     42
  66%     43
  75%     44
  80%     45
  90%     54
  95%     55
  98%     57
  99%     59
 100%     59 (longest request)
[root@nagios ~]#

Obliterate Memory Cache on Linux

As you know, Linux is faster compared to other OS’s because it saves most of the frequently used tasks in memory and reading cached stuffs from memory is faster than reading from a disk. Sometimes, the cache memory usage becomes so high that it leads to memory related issues and ultimately the server runs out of free memory.

In order to prevent this you can force the Linux OS to free up the cached memory as follows:

echo 3 > /proc/sys/vm/drop_caches

This will instantly clean up the cached memory. You can run the above command every hour by configuring cron as follows:

#vi clear_cache_mem.sh
   sync; echo 3 > /proc/sys/vm/drop_caches

Configure cron as follows:

#crontab -e
0 * * * * /root/clearcache.sh

Now, the cronjob will run this command thereby clearing the cached memory every hour.

The below image shows the cached memory before and after issuing the above command.

echo 3 > /proc/sys/vm/drop_caches

Installing OpenSSL on Apache 2.4.2

The following video shows how to configure and install Openssl on Apache 2.4.2. Also, it shows how you should create a CSR and Key file in order to obtain a self-signed certificate.

Here we have created a self signed certificate. In the same way, once you create the KEY and CSR files, you can use the CSR file to request for a real certificate from a certifying authority like Verisign, Digicert. The Key file should be kept in a safe place and shouldn’t be shared with anyone. Key file is used once you receive the real certificate file in order to configure the SSL certificate on the server.

Ext2 vs Ext3 vs Ext4 File Systems

The major File Systems in Linux are Ext2, Ext3 and Ext4.

Ext2 Filesystem:(Introduced in 1993. Developed by Remy Card)

– Maximum individual file-size can be from 16GB to 2TB

– Overall ext2 filesystem-size can be from 2TB to 32TB

– To create ext2 file system, issue the command as follows:

mke2fs /dev/sda1

Ext3 Filesystem:(Introduced in 2001. Developed by Stephen Tweedie)

– Starting from Linux Kernel 2.4.15 ext3 was available

– Ext3 filesystem allows journaling (tracks all filesystem changes)

– Maximum individual file-size can be from 16GB to 2TB

– Overall ext3 file system-size can be from 2TB to 32TB

– To create ext3 file system, issue the command as follows:

mkfs.ext3 /dev/sda1 (OR)
mke2fs -j /dev/sda1

-To convert ext2 to ext3 –

umount /dev/sda2
tune2fs -j /dev/sda2
mount /dev/sda2 /var

Ext4 Filesystem:(Introduced in 2008)

– Starting from Linux Kernel 2.6.19 ext4 was available.

– Ext4 supports huge individual file size and overall file system size

– Maximum individual file-size can be from 16 GB to 16 TB

– Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).

– Directory can contain a maximum of 64,000 sub-directories

– You can mount an existing ext3 file system as ext4 file system without upgrading it

– On ext4, you can turn journaling Off.

– To create ext4 file system, issue the command as follows:

mkfs.ext4 /dev/sda1 (OR)
mke2fs -t ext4 /dev/sda1

-To convert ext3 to ext4 –

umount /dev/sda1
tune2fs -O extents,uninit_bg,dir_index /dev/sda1
e2fsck -pf /dev/sda1
mount /dev/sda1 /home