Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to verify AB responses?

Tags:

apachebench

Is there a way to make sure that AB gets proper responses from server? For example:

  • To force it to output the response of a single request to STDOUT OR
  • To ask it to check that some text fragment is included into the response body

I want to make sure that authentication worked properly and i am measuring response time of the target page, not the login form.

Currently I just replace ab -n 100 -c 1 -C "$MY_COOKIE" $MY_REQUEST with curl -b "$MY_COOKIE" $MY_REQUEST | lynx -stdin .

If it's not possible, is there an alternative more comprehensive tool that can do that?

like image 635
Alexey Avatar asked Aug 03 '15 14:08

Alexey


2 Answers

You can use the -v option as listed in the man doc:

-v verbosity Set verbosity level - 4 and above prints information on headers, 3 and above prints response codes (404, 200, etc.), 2 and above prints warnings and info.

https://httpd.apache.org/docs/2.4/programs/ab.html

So it would be:

ab -n 100 -c 1 -C "$MY_COOKIE" -v 4 $MY_REQUEST

This will spit out the response headers and HTML content. The 3 value will be enough to check for a redirect header.

I didn't try piping it to Lynx but grep worked fine.

like image 187
Nick Pyett Avatar answered Nov 11 '22 05:11

Nick Pyett


Apache Benchmark is good for a cursory glance at your system but is not very sophisticated. I am currently attempting to tune a web service and am finding that AB does not measure complete response time when considering the transfer of the body. Also as you mention you can not verify what is returned.

My current recommendation is Apache JMeter. http://jmeter.apache.org/

I am having much better success with it. You may find the Response Assertion useful for your situation. http://jmeter.apache.org/usermanual/component_reference.html#Response_Assertion

like image 8
Joseph Avatar answered Nov 11 '22 06:11

Joseph