nginx高并发

1 keepalive_requests

2 keepalive_timeout

3 保持和server的长连接

参考文档:https://lanjingling.github.io/2016/06/11/nginx-https-keepalived-youhua/

 

echo "----------优化内核参数----------"
cat >> /etc/sysctl.conf << EOF
net.core.wmem_max = 16777216
net.core.rmem_max = 16777216
net.core.rmem_default = 65536
net.core.wmem_default = 65536
net.ipv4.tcp_mem = 4096 87380 4194304
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 87380 16777216
net.core.netdev_max_backlog = 500000
net.ipv4.tcp_max_syn_backlog = 819200
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 4096 65535
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_max_tw_buckets = 400000
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.neigh.default.gc_thresh1 = 20480
net.ipv4.neigh.default.gc_thresh2 = 40960
net.ipv4.neigh.default.gc_thresh3 = 81920
fs.file-max = 1048576
vm.swappiness = 0
vm.overcommit_memory = 1
vm.max_map_count = 131072
net.core.somaxconn = 65535
net.ipv4.tcp_max_orphans = 5000000
net.ipv4.tcp_orphan_retries = 1
EOF

  

posted @ 2023-01-31 15:11  第十一个程序员  阅读(25)  评论(0编辑  收藏  举报