ab压测

安装:yum install -y httpd-tools

验证:ab -V

ab -help:-n requests 要执行请求总数,默认会执行一个请求 -c concurrency 一次执行多个请求的数量,也就是并发数 -t timelimit 用于基准测试的最大秒数,使用它在固定的总时间内对服务器进行基准测试。默认情况下,没有时间限制。 -s timeout 超时之前等待的最大秒数。 默认值是30秒。 -b windowsize TCP发送/接收缓冲区的大小,以字节为单位。 -B address 进行传出连接时要绑定的地址。 -p postfile 包含数据到POST的文件。 还请记住设置-T。 -u putfile 包含PUT数据的文件。 还请记住设置-T 。 -T content-type Content-type用于POST / PUT数据的内容类型内容类型标题,例如:'application/x-www-form-urlencoded' 默认是' 'text/plain' -v verbosity verbosity 要打印多少个疑难解答信息,设置详细级别 - 4和以上打印标题信息,3和以上打印响应代码(404,200等),2和以上打印警告和信息。 -w 以HTML表的格式输出结果。默认时,它是白色背景的两列宽度的一张表。 -i 执行HEAD请求,而不是GET。 -x attributes 用作<table>的属性的字符串。 属性被插入<table here>。 -y attributes 用作<tr>的属性的字符串。 -z attributes 用作<td>的属性的字符串。 -C attribute 将cookie添加到请求。 参数通常采用名称=值对的形式。 这个字段是可重复的。 -H attribute 例如 ‘Accept-Encoding: gzip’ 插入所有普通标题行之后 -A attribute 添加基本的WWW认证,该属性是一个冒号分隔的用户名和密码,auth-username:password -P attribute 添加基本代理验证,属性是一个冒号分隔的用户名和密码,proxy-auth-username:password -X proxy:port 使用代理服务器和端口号。 -V 打印版本号并退出。 -k 使用HTTP KeepAlive功能。 -d 不要显示百分点服务表。 -S 不要显示信心估计和警告。 -q 做超过150个请求时不要显示进度。 -g filename 将收集的数据输出到gnuplot格式文件。 -e filename 输出提供百分比的CSV文件。 -r 不要退出套接字接收错误。 -h 显示使用情况信息(此消息)。 -Z ciphersuite 密码套件指定SSL / TLS密码套件(请参阅openssl密码) -f protocol 指定SSL / TLS协议 (SSL3, TLS1, TLS1.1, TLS1.2 or ALL)

执行:ab -c 10 -n 100 -k -r http://47.104.x.x:81/

返回:
Benchmarking 47.104.x.x (be patient).....done Server Software: nginx/1.12.0 # 服务器软件版本 Server Hostname: 47.104.x.x # 请求的URL Server Port: 81 # 请求的端口号 Document Path: / # 请求的服务器的路径 Document Length: 11270 bytes # 单个请求页面长度 单位是字节 Concurrency Level: 10 # 并发数 Time taken for tests: 19.130 seconds # 总过耗时124s Complete requests: 100 # 总请求次数 Failed requests: 0 # 失败的请求 Write errors: 0 Total transferred: 1140400 bytes # 总共传输的字节数 http头信息 HTML transferred: 1127000 bytes # 实际页面传递的字节数 Requests per second: 5.23 [#/sec] (mean) # 每秒多少个请求 Time per request: 1913.021 [ms] (mean) # 平均每个用户等待多长时间 Time per request: 191.302 [ms] (mean, across all concurrent requests) # 服务器平均用多长时间处理 Transfer rate: 58.22 [Kbytes/sec] received # 每秒获取多少数据 Connection Times (ms) min mean[+/-sd] median max Connect: 0 40 197.2 0 1002 Processing: 2 1824 1687.0 1426 10556 Waiting: 1 813 1199.9 438 8754 Total: 2 1864 1679.4 1429 10556 Percentage of the requests served within a certain time (ms) 50% 1429 # 50%的用户的请求 1429ms内返回 66% 2035 75% 2493 80% 2845 90% 3449 95% 5174 98% 7855 99% 10556 100% 10556 (longest request)

原文地址:https://www.cnblogs.com/yaohu/p/11592719.html