Performance Testing with Apache Bench

Performance Testing with Apache Bench
COMMENTS ()
Tweet

Apache Bench, or ‘ab’, is a very powerful, and yet simple to use command line utility for measuring the performance of your application under certain load. It is a freeware and bundled with Apache web server.

Apache Bench also has the capability to measure following performance key metrics:

  • Throughput
  • Response Time
  • No of concurrent users load
  • Total Test Time

Another important benefit of using Apache bench is that it has a low memory footprint, as well as uses low CPU utilization.

How to start

Apache Bench is bundled with apache source on Linux and on Windows following are popular options:

  • XAMPP
  • Wamp Server

Download any of the above packages on your Windows and Install. After installation open command prompt and go to the installation directory and open ‘…/apache/bin’ directory.

Apache Bench Command line

Enter ‘ab –h’ on command prompt to see help on different commands:

apache bench

As ab help shows we can achieve much more through ‘ab’, but for this blog we will keep our focus to following specific scenario:

Measure the performance of an HTTP API (performs Login functionality), on 5 users/sec load for 1 min.

In this, the parameters required are as follows:

  • n (number of requests) would be = 5 x 60 = 300
  • c (number of concurrent requests) = 300 / 60 =
  • p (file path to post request data)
  • T (content-type as header parameters)
  • H (Additional values as header)

And URL to post request. Once you have all the data available, finalize the command and execute from command prompt inside (…/apache/bin) directory

ab -n 300 -c 5  -p request_data.txt -T Application/xml -H "Session-Token: 1e7b9d23bde3c30554f2a32242e7706658fbeb20d4f6c44e1f3e3b4eff279e9c" -H "device-key: 3dd1f13a-44f8-4f46-a970-5479b1818033" -k http://<server_name>:<port>/http.api?command=value

Understanding Output

Following are the few important parameters which will help in interpreting the ‘ab’ output correctly:

Concurrency Level: Number of concurrent requests load kept on server till 300 count is reached.

Time taken for tests: This time will be variable if you’re testing against a number of requests.

Complete requests: Number of requests completed successfully during your test.

Requests per second: Number of requests processed per second by the server and can also be termed as Throughput, you will often cite this value as an indicator of how fast things are moving.

apache bench

CALL

USA408 365 4638

VISIT

1301 Shoreway Road, Suite 160,

Belmont, CA 94002

Contact us

Whether you are a large enterprise looking to augment your teams with experts resources or an SME looking to scale your business or a startup looking to build something.
We are your digital growth partner.

Tel: +1 408 365 4638
Support: +1 (408) 512 1812