Apache Benchmark

Apache Bench is a common tool for measuring the performance of HTTP servers in Linux environment.

Use verbose to debug a high number of failure requests

By default, ab assumes that the content length of a response will be the same for the duration of a test.(Treat different content length as failure.)

ab -n 1 -v 2 http://www.example.com/

You can ignore the length check by the -l option.

Unnecessary variance in network latency

Take a moment to spin up a server in the same locality as the one you intend to test and avoid running ab on localhost so that it doesn't pose as its own bottleneck.

(Waiting -- The time between the last bytes of the request and the first byte of the response, which should be close to zero.)

Use keep-alive

When sending HTTP requests, the connection made to the server is normally closed after each response. With keep-alive setting, the client maintains an underlying TCP connection open to facilitate multiple requests and response, this eliminates the slow and costly connection initialization time that would otherwise be present.

ab -k 
The minimum resources needed to keep connections open usually outweigh the cost of creating connections.

Timelimit option

To run load test for a specified period of time.

Need to pass the -n option in the correct order for the -n option to be effective:

ab -t 60 -n 10000000   http://www.example.com/

if the -n number of request is not specified, ab will default to a maximum number of 50,000 requests and immediately terminate the run.

Better simulate a realistic load scenario

Most web services run applications with different degree of complexity.

While ab can perform concurrent requests to a single URL, it cannot do the same across

Create a text file, with the target URLs list, and the use the `parallel` command to run ab in parallel.

cat myurls.txt | parallel "ab -n 10000 -c 10 {}"

results matching ""

    No results matching ""