Simple Web Load Testing Using Apache Benchmarking (AB)

 

For any web application, the most common questions that clients ask are:

  • Number of requests currently web applications can handle
  • Number of concurrent users and requests that app can handle in a particular time
  • Number of concurrent users performing “m” number of requests

Every client wants to check the server configuration capacity regarding users, requests and time. To meet this requirement, we need load testing tools.

Load testing is the process of putting demand on a software system or computing device and measuring its response. Load testing is performed to determine a system’s behavior under both normal and anticipated peak load conditions.

In this article, we will discuss about Apache Benchmarking Tools and usage using wamp/xampp.

ApacheBench (also known as “ab”, the command you run it with) is a tool designed to nuke an endpoint with requests and load-test web servers. It supports a wide array of parameters and options you can tweak to simulate different loads, like number of requests, number of concurrent requests, extra headers, falsified cookies, and more. ‘ab’ is often included with every Apache installation.

The apache benchmark tool is very basic, and while it will give you a solid idea of some performance, it is a bad idea to only depend on it if you plan to have your site exposed to serious stress in production.

Let’s start using apache benchmarking. Open command prompt and point to wamp and xamp folder into computer. Select folder bin in apache folder in wamp/xamp folder in command line. By default, in wamp/xamp server, apache benchmarking is installed in apache.

Type “ab” in command prompt (apache/bin folder) to display initial help commands.

The simplest test you can do is to perform 1000 requests, 10 at a time (which approximately simulates 10 concurrent users getting 100 pages each – over the length of the test).

-n 1000 is the number of requests to make.

-c 10 tells AB to do 10 requests at a time, instead of 1 request at a time, to better simulate concurrent visitors (vs. sequential visitors).

-k sends the KeepAlive header, which asks the web server to not shut down the connection after each request is done, but to instead keep reusing it.

In above sample test, we are also sending the extra header Accept-Encoding: gzip, deflate because mod_deflate is almost always used to compress the text/html output 25%-75% – the effects of which should not be dismissed due to it’s impact on the overall performance of the web server (i.e., can transfer 2x the data in the same amount of time, etc).

Based on above tests, the number of requests per second: 22.76

Multiply by 60 for minute and number of requests per minute are: 1356.6

When compared to real world application, it’s slower compared to many sample sites. My web application won’t handle many concurrent users more than 10,000. Based on my website load, I will increase my server capacity and implement performance in all ways.

More Examples:

1 concurrent user doing 100 page hits

This is 100 sequential page loads by a single user:

This shows you how well the web-server will handle a simple load of 1 user doing a number of page loads.

5 concurrent users each doing 10 page hits

This is 100 page loads by 5 different concurrent users and each user is doing 10 sequential pages loads.

This represents a peak load of a website that gets about 50,000+ hits a month. Congratulations, your website / business / idea has made it (and no doubt is on its way up).

10 concurrent users each doing 10 page hits

This is 100 page loads by 10 different concurrent users, each user is doing 10 sequential pages loads.

This is where the load starts to really stress test the web-server, as 10 concurrent (simultaneous) users is a lot of traffic. Most websites will be lucky to see 1 or 2 users (visitors) a minute… So let me say it again, 10 users per second is a lot of traffic!

30 concurrent users each doing 20 page hits

This is 600 page loads by 30 different concurrent users, each user is doing 20 sequential pages loads.

90 concurrent users each doing 30 page hits

This is 2700 page loads by 90 different concurrent users, each user is doing 30 sequential pages loads.

Limitations:

  • Its simple tools, there are many better tools than apache benchmarking
  • Load testing can performed with only max 20,000 concurrent users
  • Https is not supported

Conclusion:

Apache Benchmarking is a simple tool for writing any code, just by few commands. There are also better tools than apache benchmarking. As PHP developer, without using any other software or learning new tools, you can test load of any application and improve while developing itself. There are many other ways we can improve application performance or speed using optimization techniques and cache techniques.

No Comments

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.