tomcat8的连接配置如下:
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
maxThreads="1000"
minSpareThreads="100"
prestartminSpareThreads = "true"
maxQueueSize = "100"
/>
<Connector port="8080" protocol="org.apache.coyote.http11.Http11Nio2Protocol"
connectionTimeout="30000"
redirectPort="8443"
maxConnections="2000"
executor="tomcatThreadPool"
enableLookups="false"
acceptCount="100"
maxPostSize="-1"
compression="on"
disableUploadTimeout="true"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
acceptorThreadCount="2"
compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript"
URIEncoding="utf-8"
/>
protocol用的是:org.apache.coyote.http11.Http11Nio2Protocol,如果配置protocol="HTTP/1.1"就是用的
org.apache.coyote.http11.Http11NioProtocol
,源代码如下,在Connector类中的Connector的构造方法:
public Connector(String protocol) {
boolean aprConnector = AprLifecycleListener.isAprAvailable() &&
AprLifecycleListener.getUseAprConnector();
if ("HTTP/1.1".equals(protocol) || protocol == null) {
if (aprConnector) {
protocolHandlerClassName = "org.apache.coyote.http11.Http11AprProtocol";
} else {
protocolHandlerClassName = "org.apache.coyote.http11.Http11NioProtocol";
}
} else if ("AJP/1.3".equals(protocol)) {
if (aprConnector) {
protocolHandlerClassName = "org.apache.coyote.ajp.AjpAprProtocol";
} else {
protocolHandlerClassName = "org.apache.coyote.ajp.AjpNioProtocol";
}
} else {
protocolHandlerClassName = protocol;
}
Executor中的maxThreads和maxConnections是在AbstractProcotol中,如下:
public int getMaxThreads() { return endpoint.getMaxThreads(); }
public void setMaxThreads(int maxThreads) {
endpoint.setMaxThreads(maxThreads);
}
public int getMaxConnections() { return endpoint.getMaxConnections(); }
public void setMaxConnections(int maxConnections) {
endpoint.setMaxConnections(maxConnections);
}
到此为止,server.xml中相关的配置就通过源码解释完毕了。