模式BIO
该模式没有经过啥优化处理,几百并发性能低下
修改tomcat/conf/server.xml中connector节点为以下,尤其protocol内容
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxThreads="2000" acceptCount="1000" maxConnections="102400" maxHttpHeaderSize="8192" minSpareTheads="100" maxSpareTheads="1000" minProcessors="100" maxProcessors="1000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" URIEncoding="utf-8" disableUploadTimeout="true" useBodyEncodingForURI="true" />
模式NIO
利用JAVA的异步IO技术,no blocking IO技术
修改tomcat/conf/server.xml中connector节点为以下,尤其protocol内容
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000" redirectPort="8443" maxThreads="2000" acceptCount="1000" maxConnections="102400" maxHttpHeaderSize="8192" minSpareTheads="100" maxSpareTheads="1000" minProcessors="100" maxProcessors="1000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" URIEncoding="utf-8" disableUploadTimeout="true" useBodyEncodingForURI="true" />
模式APR
要额外安装插件,运行高并发应用的首选模式
在Windows上配置此模式要安装apr支持
在https://tomcat.apache.org/download-native.cgi下载Native,下载后将对就的tcnative-1.dll放到jdk/bin/下
修改tomcat/conf/server.xml中connector节点为以下,尤其protocol内容
启动后命令行显示["http-apr-8080"]
<Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol" connectionTimeout="20000" redirectPort="8443" maxThreads="2000" acceptCount="1000" maxConnections="102400" maxHttpHeaderSize="8192" minSpareTheads="100" maxSpareTheads="1000" minProcessors="100" maxProcessors="1000" enableLookups="false" compression="on" compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain" URIEncoding="utf-8" disableUploadTimeout="true" useBodyEncodingForURI="true" />