nginx 高併發配置 1萬併發

2021-08-20 17:13:15 字數 1753 閱讀 3381

系統層優化

系統 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  

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記憶體

nginx高併發配置

nginx配置及說明 worker processes 8 nginx 程序數,建議按照cpu 數目來指定,一般為它的倍數。worker cpu affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000...

nginx高併發配置

nginx配置及說明 worker processes 8 nginx 程序數,建議按照cpu 數目來指定,一般為它的倍數。worker cpu affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000...

高併發配置

其實,對於 nginx tomcat 等這種 web 伺服器,都提供了 backlog 引數設定入口,當然它們都會有預設值,通常這個預設值都不會太大 包括核心預設的半連線佇列和全連線佇列長度 如果應用併發訪問非常高,只增大應用層 backlog 是沒有意義的,因為可能核心引數關於連線佇列設定的都很小...