当前位置 博文首页 > xzh_blog:tomcat默认最大线程数、等待队列长度、连接超时时间

    xzh_blog:tomcat默认最大线程数、等待队列长度、连接超时时间

    作者:[db:作者] 时间:2021-08-19 13:31

    tomcat默认的最大线程数是200,当线程数达到200后,将新的线程加入等待队列,默认的等待队列是100,当等待队列达到100后,直接拒绝此次请求返回connection?refused。

    连接超时时间默认为20秒。

    来着tomcat官方文档http://tomcat.apache.org/tomcat-7.0-doc/config/http.html

    AttributeDescription
    acceptCountThe 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.
    connectionTimeoutThe number of milliseconds this?Connector?will wait, after accepting a connection, for the request URI line to be presented. Use a value of -1 to indicate no (i.e. infinite) timeout. The default value is 60000 (i.e. 60 seconds) but note that the standard server.xml that ships with Tomcat sets this to 20000 (i.e. 20 seconds). Unless?disableUploadTimeout?is set to?false, this timeout will also be used when reading the request body (if any).
    keepAliveTimeoutThe number of milliseconds this?Connector?will wait for another HTTP request before closing the connection. The default value is to use the value that has been set for the?connectionTimeout?attribute. Use a value of -1 to indicate no (i.e. infinite) timeout.
    maxConnections

    The maximum number of connections that the server will accept and process at any given time. When this number has been reached, the server will accept, but not process, one further connection. This additional connection be blocked until the number of connections being processed falls below maxConnections at which point the server will start accepting and processing new connections again. Note that once the limit has been reached, the operating system may still accept connections based on the acceptCount setting. The default value varies by connector type. 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 the default is 10000. For APR/native, the default is 8192.

    For NIO only, setting the value to -1, will disable the maxConnections feature and connections will not be counted.

    maxThreadsThe 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. Note that if an executor is configured any value set for this attribute will be recorded correctly but it will be reported (e.g. via JMX) as -1 to make clear that it is not used.

    注意

    单个tomcat能支持的最大工作线程数还和Linux CPU有关,现在一般服务器都是多核,可支持最大线程数800。

    另外,Linux单个进程的最大线程数是1024。这个限制可以在 /usr/include/bits/local_lim.h 中查看(ulimit -l)。

    流程图

    cs
    下一篇:没有了