/etc/security/limits.conf
,添加 * soft nofile 65536
和 * hard nofile 65536
,提升并发连接数上限。/etc/sysctl.conf
,设置 net.core.somaxconn=65535
、net.ipv4.tcp_tw_reuse=1
、net.ipv4.tcp_tw_recycle=1
,增强网络性能。/etc/rc.local
中添加 echo never /sys/kernel/mm/transparent_hugepage/enabled
,避免内存碎片。conf/server.xml
中配置 Executor
,设置 maxThreads
(最大线程数,建议200-500)、minSpareThreads
(最小空闲线程数,建议50-100)。org.apache.coyote.http11.Http11NioProtocol
协议,提升I/O性能。compression="on"
参数,启用Gzip压缩。connectionTimeout
(建议30000ms)和 acceptCount
(建议100-200),避免连接堆积。-Xms
(初始堆)和 -Xmx
(最大堆)为物理内存的80%,例如 -Xms2g -Xmx2g
,避免频繁GC。-XX:+UseG1GC
,优化大内存场景下的垃圾回收效率。conf/server.xml
中的 Server
标签,避免暴露敏感信息。