Tomcat8 配置NIO

conf/server.xml

打开:<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="1000" minSpareThreads="350" />

  • 修改链接参数:
    • 默认值:
        <Connector 
            port="8080" 
            protocol="HTTP/1.1" 
            connectionTimeout="20000" 
            redirectPort="8443" 
        />
    • 修改为:
        <Connector 
           port="8080" 
           protocol="org.apache.coyote.http11.Http11Nio2Protocol" 
           connectionTimeout="20000" 
           redirectPort="8443" 
           enableLookups="false" 
           acceptCount="100" 
           maxThreads="200" 
           minSpareThreads="10" 
           compression="on" 
           compressionMinSize="2048" 
           compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,application/javascript" 
           URIEncoding="utf-8"
        />
    • 重点参数解释:
      • protocol,Tomcat 8 设置 nio2 更好:org.apache.coyote.http11.Http11Nio2Protocol
      • protocol,Tomcat 6 设置 nio 更好:org.apache.coyote.http11.Http11NioProtocol
      • enableLookups,禁用DNS查询
      • acceptCount,指定当所有可以使用的处理请求的线程数都被使用时,可以放到处理队列中的请求数,超过这个数的请求将不予处理,默认设置 100
      • maxThreads,最大并发数,默认设置 200
      • minSpareThreads,Tomcat初始化时创建的线程数,默认设置 10
posted on 2016-05-11 15:17  zhaofeng555  阅读(1416)  评论(0编辑  收藏  举报