想对自己写的简单http服务器进行压力测试,网上主要是是ab或webbench,ab的测试结果较为全面
安装命令:
yum -y install httpd-tools
测试命令
ab -c 10 -n 10 http://www.baidu.com/(简单测试使用这两个参数就够用了)
-n表示总共发送的请求数
-c表示每次并发的请求数
测试结果翻译:
服务器软件:BWS / 1.1
服务器主机名:www.baidu.com
服务器端口:80
文档路径:/
文档长度:111935字节
并发级别:10
测试时间:0.109秒
完成请求:10
失败的请求:9
(连接:0,接收:0,长度:9,例外:0)
传输总数:1130674字节
HTML传输:1121072字节
每秒请求数:91.44 [#/秒](平均值)
每个请求的时间:109.360 [ms](平均值)
每个请求的时间:10.936 [ms](意味着跨所有并发请求)
传输速率:10096.69 [Kbytes / sec]收到
连接时间(ms)
分钟平均值[+/- sd]中值最大值
连接:4 5 0.7 5 5
处理:49 80 19.6 90 104
等待:12 27 17.1 22 70
总计:53 85 20.0 95 109
在特定时间内服务的请求的百分比(毫秒)
50%95
66%97
75%102
80%106
90%109
95%109
98%109
99%109
100%109(最长请求)
测试结果
我的http并发量卡在了五千左右
出现:Connection reset by peer
原因:服务器的并发连接超过其承载量,服务器会将其中一些连接给断掉
成功结果
Server Software:
Server Hostname: 122.152.250.142
Server Port: 8080
Document Path: /
Document Length: 203 bytes
Concurrency Level: 10
Time taken for tests: 13.623 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Non-2xx responses: 1000
Total transferred: 264000 bytes
HTML transferred: 203000 bytes
Requests per second: 73.40 [#/sec] (mean)
Time per request: 136.235 [ms] (mean)
Time per request: 13.623 [ms] (mean, across all concurrent requests)
Transfer rate: 18.92 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 76 253.6 10 1013
Processing: 0 56 222.1 11 1885
Waiting: 0 52 220.8 11 1885
Total: 1 132 393.3 13 2890
Percentage of the requests served within a certain time (ms)
50% 13
66% 22
75% 22
80% 23
90% 219
95% 1012
98% 1764
99% 2031
100% 2890 (longest request)