定位瓶颈与总体思路
Apache 配置优化
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 256
MaxRequestWorkers 256
MaxConnectionsPerChild 1000
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 256
MaxConnectionsPerChild 10000
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 30 days"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType application/javascript "access plus 30 days"
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
</IfModule>
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</IfModule>
<IfModule mod_cache.c>
CacheEnable disk /
CacheRoot /var/cache/apache2
CacheDirLevels 2
CacheDirLength 1
</IfModule>
系统与内核参数调优
* soft nofile 65535
* hard nofile 65535
使会话生效(或重登):ulimit -n 65535sysctl -p 生效):net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.ip_local_port_range = 1024 65535
vm.swappiness = 10
内容交付与架构优化
验证与回滚
httpd -t → 灰度/低峰滚动重启 systemctl restart httpd → 观察指标与错误日志。top/vmstat/iostat/ss -s/netstat -s 观察资源与连接;用 ab/wrk/siege 做基线压测,对比 RPS、P95/P99 延迟、错误率。