linux内核优化:
/etc/security/limits.conf
* hard nofile 391316
* soft nofile 391316
* nproc soft nproc 391316
* hard nproc 391316
vi /etc/sysctl.conf
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 1024 65000
vm.overcommit_memory = 1
net.core.somaxconn = 10240
fs.file-max = 391316
echo never > /sys/kernel/mm/transparent_hugepage/enabled
或者
vi /etc/rc.d/rc.local
ulimit -n 102400
ulimit -HSn 102400
sysctl -w net.ipv4.tcp_syncookies=1
sysctl -w net.ipv4.tcp_fin_timeout=30
sysctl -w net.ipv4.tcp_timestamps=0
sysctl -w net.ipv4.tcp_tw_reuse=1
sysctl -w net.ipv4.ip_local_port_range="1024 65000"
sysctl -w vm.overcommit_memory=1
sysctl -w net.core.somaxconn=262144
sysctl -w net.ipv4.tcp_max_tw_buckets=262144
执行"sysctl -p"使参数生效
mysql 优化:
mysql.d/limits.conf
open_files_limit = 102400
redis 优化:
[Service] centos7
LimitNOFILE=infinity
nginx 优化:
worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;
#worker_processes auto;
worker_rlimit_nofile 102400;
events {
use epoll;
worker_connections 65535;
}
http{
keepalive_timeout 300s;
keepalive_requests 50000;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server{
location /{
proxy_pass $SERVER_ADDRESS;
proxy_connect_timeout 75;
proxy_send_timeout 75;
proxy_read_timeout 75;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $Host;
proxy_set_header x-forwarded-for $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection "";
proxy_set_header Accept-Encoding "";
}
}
}