我的环境是CentOS,将nofile调到了65535,nginx与php-fpm进行了简单配置,并发1000没问题。
之后看了一些网上文章,包含了很多对内核的优化,尝试了一下,并发变成700左右,提示nginx连不上php-fpm但是,php-fpm没有任何提示,好像就没有接受到请求一样,被注释掉的坑人配置如下:
45#net.core.somaxconn = 262144
46#net.core.netdev_max_backlog = 262144
47#net.ipv4.tcp_max_orphans = 262144
48#net.ipv4.tcp_max_syn_backlog = 262144
49
50#net.ipv4.tcp_max_tw_buckets = 6000
51#net.ipv4.tcp_timestamps = 0
52#net.ipv4.tcp_tw_reuse = 1
53#net.ipv4.tcp_tw_recycle = 1
54#net.ipv4.tcp_fin_timeout = 1
55#net.ipv4.tcp_synack_retries = 1
56#net.ipv4.tcp_syn_retries = 1
57#net.ipv4.tcp_keepalive_time = 30
58#net.ipv4.ip_local_port_range = 1024 65535
之后看了一些网上文章,包含了很多对内核的优化,尝试了一下,并发变成700左右,提示nginx连不上php-fpm但是,php-fpm没有任何提示,好像就没有接受到请求一样,被注释掉的坑人配置如下:
45#net.core.somaxconn = 262144
46#net.core.netdev_max_backlog = 262144
47#net.ipv4.tcp_max_orphans = 262144
48#net.ipv4.tcp_max_syn_backlog = 262144
49
50#net.ipv4.tcp_max_tw_buckets = 6000
51#net.ipv4.tcp_timestamps = 0
52#net.ipv4.tcp_tw_reuse = 1
53#net.ipv4.tcp_tw_recycle = 1
54#net.ipv4.tcp_fin_timeout = 1
55#net.ipv4.tcp_synack_retries = 1
56#net.ipv4.tcp_syn_retries = 1
57#net.ipv4.tcp_keepalive_time = 30
58#net.ipv4.ip_local_port_range = 1024 65535