When making web applications that utilize more server resources, we want to optimize our web pages and hosting servers as much as possible. So understanding the performance of our web pages on servers will help us to take the proper optimization tweaks on both pages and servers.
We already know that almost web servers ( even cheap shared hosting ) can provide an average performance on low traffic. But when we have more traffic, these servers will fail to serve our pages for all visitors.
That means, the performance and scalability testing have an important role in web applications. Now we are going to familiarize three simple but efficient command line tools for load test.
sudo apt-get install httperf
httperf --server yourdomain.com --port 80 --num-conns 10 --rate 1
server:- Specifies the IP hostname of the server. By default, the hostname “localhost” is used.
port:- This option specifies the port number on which the web server is listening for HTTP requests. By default, httperf uses port number 80.
num-conns:- This specifies the total number of connections to create.
rate:- Specifies the fixed rate at which connections or sessions are created.
In our exemple, it’s running 10 connections and rate of 1 connection per second.
ApacheBench (ab) is a single-threaded command line tool to measure the performance of HTTP web servers. Originally designed for the Apache HTTP Server & it is generic enough to test any web server.
apt-get install apache2-utils
ab -n 1000 -c 5 yourdomain.com
n:- The number of requests to perform for the benchmarking session. The default is 1 to just perform a single request which usually leads to non-representative benchmarking results.
c:- Number of multiple requests to perform at a time. Default is one request at a time.
In this example, it’s sending 1000 number of 5 concurrency requests.
ab -kc 20 -t 30 yourdomain.com
The above example open 20 connections and keep alive the connections sending requests to the Web server for 30 seconds.
Siege is a multi-threaded http load testing and benchmarking utility.
apt-get install siege
siege -b -c 100 -r 10 yourdomain.com
Running with 100 concurrent connections to the website, running the test in a loop 10 times.