Failed requests by length in my ApacheBench load test result

爱⌒轻易说出口 提交于 2019-11-30 01:35:24

Run ab with the -v 2 parameter, meaning verbosity level 2. This will dump the response headers. If your requests are not using chunked encoding, you will see a "Content-Length" header indicating the size of each response.

gw:~$ ab -n 1 -v 2 "http://whatever.com/"

...

LOG: header received:
HTTP/1.0 200 OK
...
Content-Length: 1568399

If your responses use chunked encoding, then the length is not known until the transfer ends. Usually chunked encoding is only used for compressed responses, and ApacheBench doesn't do compression by default.

If it is compressing the responses for whatever reason that might explain it; the compressed length depends on the content.

You can also use curl -i and the --compress option to see the response headers to a single request with and without compression.

Use tcpdump

Open qty 2 terminal/shell windows or just use screen.

In the first window, use tcpdump to capture transmission data from/to your NIC (eth0) to a file:

sudo tcpdump -s 9999 -i eth0 -w myfile.txt

In the second window, fire off your ab command:

ab -n 500 -c 200 http://domain.com/test/index.php

When that's all done, parse the file with strings and grep:

strings myfile2.txt | grep -C 3 "200 OK"

You should be able to monitor all the data segments from there by eyeballing or grep'ing the results.

ab assumes that all responses are the same. It looks at the content-length of the first response, and then compares others to that.

From the man page:

Document Length
  This is the size in bytes of the first successfully returned document. 
  If the document length changes during  testing,  the  response  is 
  considered an error.

So if your first request contains following data:

{"hostname":"nodecellar-1-dwfxd","serverip":"10.1.3.3"}

And the next one is:

{"hostname":"nodecellar-1-dwfxd","serverip":"10.1.3.30"}

ab will fail with a Length error, since the output is one character longer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!