Tomcat 8 调优配置
Tomcat 8 调优主要涉及以下几个方面:
- 内存设置
- 连接器(Connector)配置
- 线程池配置
- 其他性能调整
以下是一些关键配置的示例:
- 内存设置(
setenv.sh
或setenv.bat
):
export CATALINA_OPTS="-Xms512M -Xmx1024M -XX:MaxPermSize=256M"
- 连接器(HTTP/1.1)配置(
server.xml
):
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/json"/>
- 线程池配置(
server.xml
):
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="200" minSpareThreads="20"/>
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
... />
- 其他性能调整(
context.xml
):
<Resources>
<PostResources base="file://${catalina.home}/webapps/your-app" />
<JarResources base="file://${catalina.home}/lib/" />
<JarResources base="file://${catalina.home}/lib/tomcat/" />
<JarResources base="file://${catalina.home}/bin/" />
</Resources>
根据具体应用场景,可以调整其他参数以提高性能,如调整JVM的垃圾收集策略、调整日志级别、配置JMX等。
评论已关闭