-
Notifications
You must be signed in to change notification settings - Fork 5
nginx相关优化
Guang Chen edited this page May 22, 2016
·
2 revisions
# increase socket max connection
sysctl -w net.core.somaxconn=4000 # for docker application this must be set both in host and container and give container proper priviledge
# increase ulimit
echo "* soft niofile 65535" >> /etc/security/limits.conf
echo "* hard niofile 65535" >> /etc/security/limits.conf
nginx.conf
worker_processes 12; # based on processor core
events {
worker_connections 20000; # increase worker connections
# multi_accept on;
}
http {
...
# lower timeout
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
# turn off access log
access_log off;
...
}
site configuration
upstream backend {
server xxx;
server xxx-another-ip-if-it-has; # multiple address will increase the ability of making conenction
keepalive 512; # keep backend connection alive
}
server {
location / {
...
# use http 1.1
proxy_set_header Connection "";
proxy_http_version 1.1;
...
}
}