Basic use of Ab tools

About Ab

ab is the stress test tool that comes with apache, and ab is the abbreviation of the apachebench command.

ab can not only perform website access stress testing on apache servers, but also perform stress testing on other types of servers.

ab is a very useful stress testing tool that comes with httpd. The ab command will create multiple concurrent access threads to simulate multiple visitors accessing a URL address at the same time.

It can be used to test the load pressure of apache, and it can also be used to test the pressure load performance of other web servers such as nginx, lighthttp, tomcat, and IIS.

Official website: https://httpd.apache.org/docs/2.4/programs/ab.html

Example: http://www.cnblogs.com/qmfsun/p/6476290.html

Centos installation

install ab

yum -y install httpd-tools

View version

[root @ gzf ~] # ab -V

[root@gzf~]# which ab

Parameter Description

View help

[root@tj-32-42 ~]# ab --help

ab: wrong number of arguments

Usage: ab [options] [http[s]://]hostname[:port]/path

Options are:

-n Number of requests to execute, one request will be executed by default

-c The number of multiple requests to execute at a time, the default is one request at a time.

-t Maximum number of seconds for benchmarking, use it to benchmark the server in a fixed total time. By default, there is no time limit.

-s Maximum number of seconds to wait before timing out. The default value is 30 seconds.

-b TCP send/receive buffer size in bytes.

-B The address to bind to when making outgoing connections.

-p File containing data to POST. Also remember to set -T.

-u File containing PUT data. Also remember to set -T.

-T Content-type Content-type for POST/PUT data Content-type header, eg: 'application/x-www-form-urlencoded' Default is 'text/plain'

-v verbosity How many troubleshooting messages to print, set verbosity - 4 and above print header information, 3 and above print response codes (404, 200, etc.), 2 and above print warnings and info.

-w Print the result in an HTML table.

-i Use HEAD instead of GET.

-x String to use as an attribute of <table>. Attributes are inserted into <table here>.

-y String to use as an attribute of <tr>.

-z String to use as an attribute of <td>.

-C Add cookies to the request. Parameters usually take the form of name=value pairs. This field is repeatable.

-H attribute such as 'Accept-Encoding: gzip' is inserted after all normal header lines. (repeat)

-A Add basic WWW authentication, this attribute is a colon-separated username and password, auth-username:password

-P Add basic proxy authentication, the attribute is a colon-separated username and password, proxy-auth-username:password

-X Use proxy server and port number.

-V Print the version number and exit.

-k Use HTTP KeepAlive feature.

-d Do not display percentile service table.

-S Do not display confidence estimates and warnings.

-q Don't show progress when doing more than 150 requests.

-g Output the collected data to a gnuplot format file.

-e Output a CSV file giving percentages.

-r Do not exit socket receive errors.

-h Display usage information (this message).

-Z cipher suites specify SSL/TLS cipher suites (see openssl ciphers)

-f specify SSL/TLS protocol (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

 grammar

ab [ -A auth-username:password ] [ -b windowsize ] [ -B local-address ] [ -c concurrency ] [ -C cookie-name=value ] [ -d ] [ -e csv-file ] [ -f protocol ] [ -g gnuplot-file ] [ -h ] [ -H custom-header ] [ -i ] [ -k ] [ -l ] [ -mHTTP-method ] [ -n requests ] [ -p POST-file ] [ -P proxy-auth-username:password ] [ -q ] [ -r ] [ -s timeout ] [ -S] [ -t timelimit ] [ -T content-type ] [ -u PUT-file ] [ -v verbosity] [ -V ] [ -w ] [ -x <table>-attributes ] [ -Xproxy[:port] ] [ -y <tr>-attributes ] [ -z <td>-attributes ] [ -Z ciphersuite ] [http[s]://]hostname[:port]/path

 

Example

Get request

ab -n1 -c1 "http://192.168.32.46:8081/"

-n Number of requests to execute, one request will be executed by default

-c The number of multiple requests to execute at a time, the default is one request at a time.

Post request

ab -n1 -c1   -p "/root/gzf/ab_test/post.txt" -T "application/json" "http://192.168.32.76:81/tokenServer/get/token"

-p File containing data to POST. Also remember to set -T

-T Content-type Content-type for POST/PUT data Content-type header, eg: 'application/x-www-form-urlencoded' Default is 'text/plain'

post.txt

&clientId=098f6bcd4621d373cade4e832627b4f6&userName=admin&password=123456

Guess you like

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