AB for stress testing

Source: Internet
Author: User
Tags response code

AB is a stress testing tool that comes with Apache and can be used for simple stress testing on interfaces.

The following is a brief introduction of AB.

Format: AB [Options] [http: //] hostname [: Port]/path parameter description: -N requests number of requests to perform // number of requests executed in the test session (total number of times the page is accessed in this test ). By default, only one request is executed. -C concurrency number of multiple requests to make // number of requests generated at a time (number of concurrent requests ). The default value is one at a time. -T timelimit seconds to max. Wait for responses // The maximum number of seconds for the test. The implicit value is-N 50000. It limits the server test to a fixed total time. By default, there is no time limit. -P postfile file containing data to post // contains the post data file, which contains the jsondata, and the Content-Type Header used by the post.txt-T Content-Type Header for posting/post data, for example,-T "Application/X-WWW-form-urlencoded", if it is JSON,-T "Application/JSON" (with-P) -V verbosity how much troubleshooting info to print // set the details of the displayed information-4 or a greater value will display the header information, 3 or a greater value can display the response code (404,200, etc ), 2 or a greater value can display warnings and other information. -V displays the version number and exits. // If it is 4, you can output the response information and Response Header-W print out results in HTML tables // output the result in HTML table format. By default, it is a table of the width of the two columns of the white background. -I use head instead of get // executes the head request instead of get. -X attributes string to insert as table attributes-y attributes string to insert As tr attributes-Z attributes string to insert as TD or th attributes-C attribute add cookie, eg. -c "C1 = 1234, C2 = 2, C3 = 3" (repeatable) //-C cookie-name = value attaches a cookie to the request: Row. The typical form is a parameter pair of name = value. This parameter can be repeated and separated by commas. Tip: You can use the session implementation principle to pass the JSESSIONID parameter to achieve session persistence, such as-c "C1 = 1234, C2 = 2, C3 = 3, JSESSIONID = ff056cd16da9d71cb1_c1d56f0319f8 ″. -H attribute add arbitrary header line, eg. 'Accept-encoding: gzip' inserted after all normal header lines. (repeatable)-A attribute add basic WWW authentication, the attributesare a colon separated username and password. -P attribute add basic proxy authentication, the attributesare a colon separated username and password. //-P proxy-auth-UserName: password provides basic authentication trust for a transit proxy. The user name and password are separated by one and sent in base64 encoding format. This string is sent regardless of whether the server needs it (that is, whether the 401 authentication request code is sent. -X Proxy: Port proxyserver and port number to use-V print version number and exit-K use HTTP keepalive feature-d do not show percentiles served table. -s do not show confidence estimators and warnings. -G filename output collected data to gnuplot format file. -E filename output CSV file with percentages served-H display usage information (this message) //-attributes sets the attribute string. the defect program has various static declared fixed-length buffers. In addition, parsing command line parameters, server response headers, and other external inputs is also simple, which may have adverse consequences. It does not fully implement HTTP/1.x; only accept some 'preview' response formats. Frequent use of strstr (3) may cause performance problems, that is, you may be testing the performance of AB rather than the server.

Here is an example:

 
AB .exe-C 10-N 100-T 60-c "cookies"-P post.txt-T 'application/json'-V 4 http://xxxx.xxxx.com/lmauto/api/xxxx/order/batchSave.htm

As mentioned above:

-C has 10 concurrent users,

-N each sends 100 requests,

-T Processing 60 s in total,

-C has some interfaces that need to verify the user's login identity. Therefore, cookies are included in the double quotation marks, which are the cookies you need,

-P is the parameter file required by the POST request. Ensure that the data in the parameter file is correct,

-T is used with-P. The post parameters in this article are in JSON format, and all the parameters in 'application/json' are used ',

-V is used to print the server response and response headers at different levels. At the beginning of this stress test, the request response results were not displayed, and no exception was reported in the server log, the test result is OK. The parameter is used the next day to know that the original test result has a large error and cannot be successfully requested. (Note: as long as the server has a response (Status Code 200), AB considers the request as successful. It does not care whether the returned result is successful or failed, so be sure to confirm it, is the returned request expected)

The following is the interface URL.

The following is a 60 s test result of 1 concurrency:

 

Note: If the insert operation of the database is designed and unique, the concurrent operation of AB uses the same data file of HI, which cannot be used for data allocation, so there will be repeated reports. Continue to follow up and see if there are any solutions.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.