环境:
- nginx主机一台
- ab测试主机一台
配置已修改
修改了nginx所在系统的限制/etc/security/limits.conf,也重启了。
* soft core unlimited
* hard core unlimited
* soft nproc 100000
* hard nproc 100000
* soft nofile 100000
* hard nofile 100000
* soft memlock 32000
* hard memlock 32000
* soft msgqueue 819200
* hard msgqueue 819200
nginx的并发连接和文件限制也打开了。
[root@maple-c8-n2 ~]# cat/apps/nginx/conf/nginx.conf
#user nobody;
worker_processes 2;
#worker_cpu_affinity 01 10;
#worker_priority 10;
worker_rlimit_nofile 110000;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log error;
pid /apps/nginx//run//nginx.pid;
events {
worker_connections 110000;
multi_accept on;
use epoll;
accept_mutex on;
}
ab压测还是报错
[root@maple-c8-n1 httpd-2.3.16-beta]# ab -c 5000 -n 10000 http://10.0.0.18/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.0.0.18 (be patient)
socket: Too many open files (24)
明明nginx服务的文件限制和并发连接都已修改,并且操作系统的文件限制也已调大,并且重启还是没有效果。突然想到nginx接受网络I/O流是都是会在本地创建fd socket文件,那么ab主机发起连接也会在本地创建socket文件,Linux一切皆文件,那么将ab压测所在主机的操作系统文件限制也调大,问题得到解决。
[root@maple-c8-n1 ~]# ab -c 5000 -n 10000 http://10.0.0.18/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 10.0.0.18 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx/1.18.0
Server Hostname: 10.0.0.18
Server Port: 80
Document Path: /
Document Length: 612 bytes
Concurrency Level: 5000
Time taken for tests: 9.772 seconds
Complete requests: 10000
Failed requests: 0
Total transferred: 8450000 bytes
HTML transferred: 6120000 bytes
Requests per second: 1023.31 [#/sec] (mean)
Time per request: 4886.127 [ms] (mean)
Time per request: 0.977 [ms] (mean, across all concurrent requests)
Transfer rate: 844.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 350 254.8 325 1229
Processing: 29 590 1086.8 240 9147
Waiting: 0 584 1088.3 237 9141
Total: 61 941 1092.6 601 9382
Percentage of the requests served within a certain time (ms)
50% 601
66% 672
75% 850
80% 1152
90% 1895
95% 3234
98% 3555
99% 4001
100% 9382 (longest request)