tomcat 优化
Tomcat Connector三种运行模式(BIO, NIO, APR)的比较和优化
- BIO:
- NIO:
- APR:
BIO NIO APR
Classname AjpProtocol AjpNioProtocol AjpAprProtocol
Tomcat Version 3.x onwards 7.x onwards 5.5.x onwards
Support Polling NO YES YES
Polling Size N/A maxConnections maxConnections
Read Request Headers Blocking Sim Blocking Blocking
Read Request Body Blocking Sim Blocking Blocking
Write Response Blocking Sim Blocking Blocking
Wait for next Request Blocking Non Blocking Non Blocking
Max Connections maxConnections maxConnections maxConnections
1.Starting ProtocolHandler ["http-bio-8080"]
2.Starting ProtocolHandler ["http-nio-8080"]
3.Starting ProtocolHandler ["http-apr-8080"]
2.tomcat 连接池配置
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
3.tomcat缓存
compression 打开压缩功能
compressionMinSize 启用压缩的输出内容大小,这里面默认为2KB
compressableMimeType 压缩类型
connectionTimeout 定义建立客户连接超时的时间. 如果为 -1, 表示不限制建立客户连接的时间
<Connector port="9027" protocol="HTTP/1.1" maxHttpHeaderSize="8192" maxThreads="1000" minSpareThreads="100" maxSpareThreads="1000" minProcessors="100" maxProcessors="1000" enableLookups="false" compression="on" compressionMinSize="2048" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" connectionTimeout="20000" URIEncoding="utf-8" acceptCount="1000" redirectPort="8443" disableUploadTimeout="true"/>
4. 禁用ajp协议
<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />-->
5.jvm参数设置