AB command format:-n|--count Total number of requests, default: 5w-c|--clients concurrency, default: 100-r|--rounds test times, Default: 10-s|-sleeptime interval, default: 10 seconds-i|--min most Small concurrency, default: 0-x|--max max concurrency, default: 0-j|--step increment concurrency number-r|--runtime Overall run time, set this item the maximum number of requests is 5w-p|--postfile post data file path-u|--url test address
To use AB for post data testing. From help you can see that we need to define two of content
One is the-p parameter. Specify data that needs to be post
There is also a-t parameter that specifies the Content-type used
Eg:ab-n 3-c 3-p post.txt-t application/x-www-form-urlencoded http://192.168.1.176:8080/xx.do
In addition, post.txt inside the post data to put your JSON data, such as data={"id": "1234"} but pay attention to UrlEncode encryption, so the real content in the Post.txt is Data=%7b%22id%22%3a%221234%22%7d, and notice that you don't have to build a post.txt on Windows yourself, but instead use eclipse or notepad++ , because you build a TXT will have a special character at the beginning of the file, so that cannot parse. I was using the IntelliJ idea to develop a TXT file built with it. After doing well, you can definitely be under ab ....
the-P option specifies the location of the post file, and the-t option specifies how the post file is encoded, by default, clear text, or if - t ' application/x-www-form-urlencoded ' is specified Post file using urlencode
Note: Content-type must be set to become application/x-www-form-urlencoded
Apache Bench (AB) stress test analog POST request