当入行压力测试时出现下列错误
[root@zabbix ~]# ab -n 3000 -c 3000 http://192.168.0.2/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.0.2 (be patient)
socket: Too many open files (24)解决方法:
查看当前要以打开的文件个数
[root@zabbix ~]# ulimit -a
core file size (blocks, -c) 0data seg size (kbytes, -d) unlimitedscheduling priority (-e) 0file size (blocks, -f) unlimitedpending signals (-i) 14802max locked memory (kbytes, -l) 64max memory size (kbytes, -m) unlimitedopen files (-n) 1024pipe size (512 bytes, -p) 8POSIX message queues (bytes, -q) 819200real-time priority (-r) 0stack size (kbytes, -s) 10240cpu time (seconds, -t) unlimitedmax user processes (-u) 14802virtual memory (kbytes, -v) unlimitedfile locks (-x) unlimited调整可以打开的文件数
[root@zabbix ~]# ulimit -n 65535
重新执行该命令[root@zabbix ~]# ab -n 3000 -c 3000 http://192.168.0.2/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Licensed to The Apache Software Foundation, http://www.apache.org/Benchmarking 192.168.0.2 (be patient)
Completed 300 requestsCompleted 600 requestsCompleted 900 requestsCompleted 1200 requestsCompleted 1500 requestsCompleted 1800 requestsCompleted 2100 requestsCompleted 2400 requestsCompleted 2700 requestsCompleted 3000 requestsFinished 3000 requests Server Software: Apache/2.2.15Server Hostname: 192.168.0.2Server Port: 80Document Path: /
Document Length: 3985 bytesConcurrency Level: 3000
Time taken for tests: 4.034 secondsComplete requests: 3000Failed requests: 0Write errors: 0Non-2xx responses: 3001Total transferred: 12554896 bytesHTML transferred: 11957697 bytesRequests per second: 743.75 [#/sec] (mean)Time per request: 4033.602 [ms] (mean)Time per request: 1.345 [ms] (mean, across all concurrent requests)Transfer rate: 3039.63 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median maxConnect: 0 553 995.8 2 3061Processing: 23 284 308.2 159 3235Waiting: 22 280 308.1 156 3235Total: 95 837 1149.6 198 3809Percentage of the requests served within a certain time (ms)
50% 198 66% 394 75% 1134 80% 1347 90% 3333 95% 3696 98% 3788 99% 3795 100% 3809 (longest request)问题解决