AB command format:-n|--count Total number of requests, default: 5w-c|--clients concurrency number, default:-r|--rounds Test number, default: 10 times-s|-sleeptime interval time, default: 10 seconds-i|--min Minimum concurrent number, default: 0-x|--max Maximum concurrent number, default: 0-j|--step number of times increment concurrency-r|--runtime Overall run time, maximum number of requests when setting this item 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/xxab-n 1-c 1-p post.txt-t APPL Ication/octet-stream HTTP://172.25.33.211:8088/DSP/RTB
In addition, the post data inside the post.txt should be put in your JSON data, such as
data={"id": "1234"}
but pay attention to the UrlEncode encryption, so the content that really put in post.txt inside 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 building a TXT will have a special character at the beginning of the file, so you can't parse it. 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
Apache Bench (AB) stress test analog POST request