Tomcat线程

可以通过调节并发线程数来对tomcat自身进行优化。

tomcat中conf/service.xml配置如下:
<!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    < Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    < Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    < Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    < Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    < Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

tomcat支持多个 Connector配置,支持多个Connector共享一个线程池。

Executor 配置的是tomcat的线程池,在Connector中用executor配置线程池。可以通过调节maxThreads的值。来调节tomcat的最大线程数。


可以在tomcat的conf/web.xml中配置
    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
来管理session


猜你喜欢

转载自blog.csdn.net/G1248019684/article/details/51538335