每次迭代更改 Apache Bench 使用的 POST 数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2602841/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Changing POST data used by Apache Bench per iteration
提问by James Brady
I'm using abto do some load testing, and it's important that the supplied querystring (or POST) parameters change between requests.
我正在使用ab进行一些负载测试,重要的是提供的查询字符串(或 POST)参数在请求之间发生变化。
I.e. I need to make requests to URLs like:
即我需要向 URL 发出请求,例如:
http://127.0.0.1:9080/meth?param=0
http://127.0.0.1:9080/meth?param=1
http://127.0.0.1:9080/meth?param=2
...
to properly exercise the application.
正确行使应用程序。
ab seems to only read the supplied POST data file once, at startup, so changing its content during the test run is not an option.
ab 似乎只在启动时读取提供的 POST 数据文件一次,因此在测试运行期间更改其内容不是一个选项。
Any suggestions?
有什么建议?
采纳答案by ceejayoz
回答by Andrey Bosonchenko
Here is patched version of ab or patch: http://www.andboson.com/?p=1372
这是 ab 或补丁的补丁版本:http://www.andboson.com/?p= 1372
this version is included that patch http://chrismiles.info/dev/testing/abalso can read many post-data line by line
此版本包含补丁http://chrismiles.info/dev/testing/ab也可以逐行读取许多后期数据
upd:sample request:
更新:样品请求:
./ab -v1 -n2 -c1 -T'application/json' -ppostfile http://api.webhookinbox.com/i/HX6mC1WS/in/
./ab -v1 -n2 -c1 -T'application/json' -ppostfile http://api.webhookinbox.com/i/HX6mC1WS/in/
postfile content:
后文件内容:
{"data1":1, "data2":"4"}
{"data0":0, "x":"y"}
{"data1":1, "data2":"4"}
{"data0":0, "x":"y"}
upd2:
更新2:
also alternative https://github.com/andboson/ab-go
回答by extraplanetary
Add my recommendation for jMeter...it works very well!
添加我对 jMeter 的建议......它工作得很好!
You could also create a script that creates a second script with something like:
您还可以创建一个脚本来创建第二个脚本,例如:
ab -n 1 -c 1 'http://yoursever.com/method?param=0' & ab -n 1 -c 1 'http://yoursever.com/method?param=1' & ab -n 1 -c 1 'http://yoursever.com/method?param=2' & ab -n 1 -c 1 'http://yoursever.com/method?param=3' & ab -n 1 -c 1 'http://yoursever.com/method?param=4' &
ab -n 1 -c 1 'http://yoursever.com/method?param=0' & ab -n 1 -c 1 'http://yoursever.com/method?param=1' & ab -n 1 -c 1 'http://yoursever.com/method?param=2' & ab -n 1 -c 1 'http://yoursever.com/method?param=3' & ab -n 1 -c 1 ' http://yoursever.com/method?param=4' &
But that's only really useful if you're trying to simulate load and observe your server. The actual benchmarks will have to be collated if you want to check ab performance. At that point I'd just use jMeter. For my use, I just need to simulate load and the ab processes are light enough that running 100 like this is no problem.
但这只有在您尝试模拟负载并观察您的服务器时才真正有用。如果您想检查 ab 性能,则必须整理实际的基准测试。那时我只会使用jMeter。对于我的使用,我只需要模拟负载并且 ab 进程足够轻,像这样运行 100 是没有问题的。

