基本步驟
- 安裝ApacheBench
- 修改內(nèi)核參數(shù)/etc/sysctl.conf少辣,執(zhí)行/sbin/sysctl -p
- 測試Nginx: 修改Nginx配置耕突,測試index.html
- 測試Tomcat: 修改Tomcat配置,JVM參數(shù)
成果
- Tomcat測試:并發(fā)數(shù) 2000评架,QPS 900
內(nèi)核參數(shù)
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_syn_retries = 6
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 30
net.core.somaxconn = 8192
net.core.netdev_max_backlog = 262144
Nginx配置
worker_processes auto;
worker_rlimit_nofile 65535;
events {
use epoll;
worker_connections 65535;
}
http {
keepalive_timeout 65;
open_file_cache max=102400 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
}
Tomcat配置
tomcat:
max-connections: 10000
accept-count: 100
connection-timeout: 60000
max-threads: 500
min-spare-threads: 30
max-queue-size: 100
max-idle-time: 60000
JVM參數(shù)
-server -Xms2048m -Xmx2048m -Xmn512m