链接超时问题:
nginx 上 tcp参数优化了下
vi /etc/sysctl.conf
time_wait尽快释放和重用
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 30
然后执行 /sbin/sysctl -p 让参数生效。
用于统计当前各种状态的连接的数量的命令
—————————
#netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’
修改nginx子网站的配置
/usr/local/nginx/conf/vhost
nginx -s reload
连接数太多报错: [error] 13475#0: *16378 connect() to unix:/tmp/php-cgi.sock failed (11: Resource temporarily unavailable) while connecting to upstream,
解决方法:修改配置文件
vi ./usr/local/php/etc/php-fpm.conf
[www]
listen = /tmp/php-cgi.sock
listen.backlog = 4096
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = static
pm.max_children = 1024
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 1024
request_terminate_timeout = 0
request_slowlog_timeout = 0
slowlog = var/log/slow.log
重启下
/etc/init.d/php-fpm restart
原始配置:
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = var/log/slow.log