nginx 高并发配置(1万并发)

系统层优化
系统 socket 层优化
echo 65535 > /proc/sys/net/core/somaxconn   准许最大链接数
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle  快速回收链接
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse     重用链接
echo 0 > /proc/sys/net/ipv4/tcp_syncookies   关闭洪水抵御
系统文件层优化
ulimit -n 65535




nginx 配置层优化
nginx socket层优化 
worker_connections  10240;
nginx 层打开文件数优化
worker_rlimit_nofile 20000;




ab -n 500000 -c 20000  http://192.168.1.52/index.html
Server Software:        nginx/1.10.2
Server Hostname:        192.168.1.52
Server Port:            80


Document Path:          /index.html
Document Length:        3698 bytes


Concurrency Level:      10000
Time taken for tests:   50.253 seconds
Complete requests:      500000
Failed requests:        0
Write errors:           0
Total transferred:      1986528972 bytes
HTML transferred:       1868307258 bytes
Requests per second:    9949.62 [#/sec] (mean)
Time per request:       1005.064 [ms] (mean)
Time per request:       0.101 [ms] (mean, across all concurrent requests)
Transfer rate:          38603.91 [Kbytes/sec] received


Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0  450 101.8    448    1408
Processing:   153  543 199.3    510    2093
Waiting:        0  400 181.5    361    2016
Total:        475  993 173.4    971    2382


Percentage of the requests served within a certain time (ms)
  50%    971
  66%    997
  75%   1015
  80%   1030
  90%   1086
  95%   1156
  98%   1540
  99%   1922
 100%   2382 (longest request)


硬件配置 vm i5 4核 1G内存

猜你喜欢

转载自blog.csdn.net/zxssoft/article/details/80673254
今日推荐