How to increase number of threads in tomcat thread pool?

后端 未结 3 2033
眼角桃花
眼角桃花 2020-11-29 03:26

i just want to know How to increase number of threads in tomcat thread pool ? and what number to set the max too, i don\'t know what\'s appropriate ?

相关标签:
3条回答
  • 2020-11-29 04:02

    You would have to tune it according to your environment.

    Sometimes it's more useful to increase the size of the backlog (acceptCount) instead of the maximum number of threads.

    Say, instead of

    <Connector ... maxThreads="500" acceptCount="50"
    

    you use

    <Connector ... maxThreads="300" acceptCount="150"
    

    you can get much better performance in some cases, cause there would be less threads disputing the resources and the backlog queue would be consumed faster.

    In any case, though, you have to do some benchmarks to really know what is best.

    0 讨论(0)
  • 2020-11-29 04:07

    Sounds like you should stay with the defaults ;-)

    Seriously: The number of maximum parallel connections you should set depends on your expected tomcat usage and also on the number of cores on your server. More cores on your processor => more parallel threads that can be executed.

    See here how to configure...

    Tomcat 9: https://tomcat.apache.org/tomcat-9.0-doc/config/executor.html

    Tomcat 8: https://tomcat.apache.org/tomcat-8.0-doc/config/executor.html

    Tomcat 7: https://tomcat.apache.org/tomcat-7.0-doc/config/executor.html

    Tomcat 6: https://tomcat.apache.org/tomcat-6.0-doc/config/executor.html

    0 讨论(0)
  • 2020-11-29 04:08

    From Tomcat Documentation

    maxConnections When this number has been reached, the server will accept, but not process, one further connection. once the limit has been reached, the operating system may still accept connections based on the acceptCount setting. (The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.) For BIO the default is the value of maxThreads unless an Executor is used in which case the default will be the value of maxThreads from the executor. For NIO and NIO2 the default is 10000. For APR/native, the default is 8192. Note that for APR/native on Windows, the configured value will be reduced to the highest multiple of 1024 that is less than or equal to maxConnections. This is done for performance reasons.

    maxThreads
    The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

    0 讨论(0)
提交回复
热议问题