20-ab压力测试及nginx性能统计模块
优化的启发,打开的文件太多
Nginx 错误日志显示,打开文件数太多
系统层面
more /proc/sys/net/core/somaxconn
单个Nginx 测试index.html
没优化前
[root@/home/www]#ab -c 4000 -n 100000 http://test.demo.com/index.html Concurrency Level: 4000 Time taken for tests: 18.596 seconds Complete requests: 100000 Failed requests: 99350(Connect: 0, Receive: 0, Length: 99350, Exceptions: 0) Non-2xx responses: 99780 Total transferred: 31953900 bytes HTML transferred: 16180560 bytes Requests per second: 5377.62 [#/sec] (mean) Time per request: 743.823 [ms] (mean) Time per request: 0.186 [ms] (mean, across all concurrent requests) Transfer rate: 1678.09 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max Connect: 0 204 582.3 2 7522 Processing: 2 101 612.0 12 17019 Waiting: 2 76 287.2 12 6939 Total: 3 305 862.2 14 17019Percentage of the requests served within a certain time (ms)50% 1466% 1775% 20880% 21790% 101495% 123898% 301799% 3218100% 17019 (longest request)
优化后
[root@/home/www]#ab -c 4000 -n 100000 http://test.demo.com/index.html Concurrency Level: 4000 Time taken for tests: 8.154 seconds Complete requests: 100000 Failed requests: 0 Non-2xx responses: 100000 Total transferred: 32000000 bytes HTML transferred: 16200000 bytes Requests per second: 12263.42 [#/sec] (mean) Time per request: 326.173 [ms] (mean) Time per request: 0.082 [ms] (mean, across all concurrent requests) Transfer rate: 3832.32 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max Connect: 1 139 418.0 5 3031 Processing: 2 101 106.9 74 1542 Waiting: 2 99 106.7 73 1542 Total: 3 240 433.1 81 4542Percentage of the requests served within a certain time (ms)50% 8166% 9175% 11580% 26890% 106695% 108598% 127599% 3018100% 4542 (longest request)
ab 测试过程出现的以下问题,则是由于客户端原因造成的,而不是服务器原因,修改客户端配置既可以
Completed 1000 requests Completed 2000 requests apr_socket_recv: Connection timed out (110) Total of 2893 requests completed