linux--->ab test tool use

ab test tool use

ab introduction
  • It is a stress test tool that comes with apache. The principle is that the ab command will create multiple concurrent access threads to simulate multiple visitors accessing a URL address at the same time. Its test target is based on URL, so it can not only test the load pressure of apache, but also test the pressure of other web servers such as nginx, lighthttp, tomcat, IIS, etc.
  • The ab command has very low requirements on the computer issuing the load, it is neither very CPU-intensive nor memory-intensive. But it will cause a huge load to the target server, and its principle is similar to CC attack. You also need to pay attention when testing and using it yourself, otherwise it will put too much load at one time. It may cause the target server to run out of resources, and even cause a crash in severe cases.
ab install
  • window
    • If it is an integrated environment such as phptudy, you only need to enter the bin directory under the apache installation module through the terminal, you will see the application files of ab, and you can see the relevant information of ab through ab -v.
  • linux
    • The first way is to install apache directly to use ab
    • If you don't want to install apache, you can directly install the apache toolkit httpd-tools, you can use ab

      yum -y install httpd-tools
ab parameter description
  • -n indicates the number of requests
  • -c indicates the number of concurrent
  • -t maximum number of seconds to test
  • -T: Content-Type header information used by post data, if -T 'application/x-www-form-urlencoded'
use
  • get request

    ab -c 10 -n 10 http://www.test.api.com/?gid=2
  • post request
    • Create a file post.txt in the current directory,
      edit the file post.txt, write
      cid=4&status=1
      , which is equivalent to post passing cid, status parameter
      ab -n 100 -c 10 -p 'post.txt' -T 'application/x -www-form-urlencoded' ' http://test.api.com/ttk/auth/info/ '
  • Simulate user login
    • Please refer to the following steps: After logging in with the account and password, use the developer tool to find the cookie value (Session ID) that identifies the session, write down and copy the cookie information

      ab -n 100 -c 100 -H "Cookie: JSESSIONID=01BCDA8D30F3011A1C8136ED9B0A3ED6.server;USER.oooooooooooooooo=ab84b0125a24ecb263c6b677b989683ca26da6b4076ae09e1d5ccb8595a92a6d28233e61d860c9d0b745b0dfd8426494"  http://127.0.0.1:8007/shopCenter/zcyAccount/checkZcyAccount.do
Return parameter description
  • Time taken for tests represents the total time it took for all these requests to be processed.
  • Failed requests indicates the number of failed requests,
  • Total transferred indicates the total length of the response data of all requests, including the length of the header information and body data of each HTTP response data. Note that the length of the HTTP request data is not included here, it is only the total length of the application layer data that the web server flows to the user's PC.
  • HTML transferred represents the sum of the body data in the response data of all requests, that is, minus the length of the header information in the HTTP response data in Total transferred.
  • Requests per second throughput,
  • Time per request User average request waiting time
  • Time per requet (across all concurrent request) server average request waiting time
  • Transfer rate indicates the length of data obtained from the server for these requests in unit time, which can help to rule out whether there is a problem of excessive network traffic leading to prolonged response time
Test Concern Metrics
  • Throughput:
    • The quantitative description of the concurrent processing capability of the server, in reqs/s, refers to the number of requests processed per unit of time under the number of concurrent users. The maximum number of requests that can be processed per unit time under a certain number of concurrent users is called the maximum throughput rate.
    • Corresponding indicator: Requests per second
  • User average request waiting time
    • Time spent processing all requests / (total requests / concurrent users)
    • Corresponding indicator: Time per request
  • Server average request wait time
    • Corresponding indicator: Time per request: ***[ms] (mean, across all concurrent requests)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324814208&siteId=291194637