November 22, 2024

HTTP load testing using ApacheBenchmark and Httperf

In this article I will show some http load testing examples using two useful webserver benchmark tools, ApacheBenchmark (called ab) and Httperf.
It’s important to note that both benchmark tools do not work like a real browser but they only test the standard http payload of the web application. This means that are not loaded the assets like images, javascript or css but only the rendered HTML of the URL under test. For example, suppose we want to test the url http://mywebserver/index.html. Here is the html source of index.html page.

<html>
<head>
    <script type="text/javascript" src="http://server/jquery.min.js"></script>
</head>

<body>
<div>Test</div>
<div><img src="http://server/image.png"></div>
</body>
</html>

During test, only the index.html source page are requested, the resources “jquery.min.js” and “image.png” are not loaded. Both AB and HTTPERF can test against concurrent connections, number of loads per connection, and give understandable results. In more advanced usages Httperf also allows the creation of a series of URIs to pass, to emulate a single session. The “wsesslog” option can be used to generate a specific sequence of URI accesses. This specifies a session workload generator instead of individual requests, including the number and sequence of URI’s, request method, think-time and burst-length parameters.

There are some others advanced test tools like Siege, Jmeter, or OpenSTA which simulate a “real” usage of a web site, but will not be covered in this article. Let’s see some examples of AB and HTTPERF use.

ApacheBenchmark

$ ab -n1 -c1 -t1 -k http://mydomain.com/media.html

-n ........ 1 of HTTP requests
-c ........ 1 concurrent connections
-t ........ 1 of seconds of the teest
-k ........ enable HTTP keep-alives

 

$ ab -n10000 -c100 -t10 -k http://alfresco:8080/alfresco/d/d/workspace/SpacesStore/5a101184-beea-4b12-999e-488774c508a2/Alfresco_Developer_Guide.pdf/

$ ab -n  10000 -c100 -t10 -k http://liferay:8080/test-2/

-n ........ 10000 of HTTP requests
-c ........ 100 concurrent connections
-t ........ 10 of seconds of the test
-k ........ enable HTTP keep-alives

Httperf

$ httperf --server=mydomain.com --port=80 --uri=/web/guest/home --hog --num-conns=100 --rate=100 --num-calls=1

--num-conns ........ 100 connections - the total number of connections to create
--rate ............. 100 connections per second - the fixed rate at which connections or sessions are created
--num-call .......... 1 calls - the total number of calls to issue on each connection before closing it

 

$ httperf --server=mydomain.com --port=80 --uri=/web/guest/home --hog --rate=10 --num-conns=100	

--num-conns ........ 100 connections - the total number of connections to create
--rate ............. 10 connections per second - the fixed rate at which connections or sessions are created
--num-call .......... 1 calls - the total number of calls to issue on each connection before closing it

 

# Get a pdf document from the public Alfresco guest home
$ httperf --server=alfresco.it --port=8080 --uri=/alfresco/d/d/workspace/SpacesStore/5a101184-beea-4b12-999e-488774c508a2/Alfresco_Developer_Guide.pdf --rate=100 --hog --num-conns=1000 --num-calls=1

--num-conns ........ 1000 connections - the total number of connections to create
--rate ............. 100 connections per second - the fixed rate at which connections or sessions are created
--num-call .......... 1 calls - the total number of calls to issue on each connection before closing it

 

Related posts

Leave a Reply

Your email address will not be published.