Tag: Performance

Apache Benchmark (ab) tool acting slowly?

I recently needed to do some informal HealthDecision API concurrent session testing. I decided to try out the Apache benchmarking tool (ab).  Given that I needed something quick, I started a new HealthDecision session in the browser and used Chrome Developer Tools’ copy as cUrl functionality to get the headers and the POST data.  This obviously worked on the command line, but each request was taking close to six seconds when I used ab!

The request something like this…

ab -n 1 -c 1 -H 'X-Session-ID: XXXXXX' -H 'User-Agent: curl/Farhan testing'-H 'Connection: keep-alive' -H 'X-Session-Passphrase: XXXXXXX' -H 'X-API-Key: XXXXXXXXXXXXX' -T 'application/json' -p post-data.txt 'https://dev.healthdecision.org/...'

It didn’t make much sense at first sight because the exact same request was less than half a second every time.  I tried running with output turned on (-v 4) and could see that it was waiting after it received the response from the server.  After some more troubleshooting, I finally realized that it was the keep-alive header causing ab to wait for the connection to close!

Lesson learned, pay very close attention to the headers.