Tomcat - maxThreads vs maxConnections

In Tomcat server.xml what are maxThreads and maxConnections
I understand that maxConnections is the number of connections open to the server
And maxThreads is the maximum number of request processing threads
But how the two configuration options work together, obviously you will not set maxConnections to 1000 and maxThreads to 10
What is the relationship between the two configuration options?

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="250" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" connectiontimeout="20000"/> 

thank

+42
java tomcat
Jul 10 '14 at 2:04
source share
2 answers

Tomcat can work in two modes:

BIO (one thread per connection) or NIO (much more connections than threads).

Tomcat7 is BIO by default, although the consensus seems to be "not using Bio because Nio is better in every way." You set this using the "protocol" parameter in the server.xml file - the BIO will be "HTTP1.1" or "org.apache.coyote.http11.Http11Protocol", and the NIO will be "org.apache.coyote.http11.Http11NioProtocol"

If you use BIO, I believe that they should be more or less the same. If you use NIO, then in fact "maxConnections = 1000" and "maxThreads = 10" may even be reasonable. By default, maxConnections = 10,000 and maxThreads = 200 are used. With NIO, each thread can serve any number of connections, switching back and forth, but keeping the connection, so you don’t have to do all the usual handshakes, which are especially time-consuming with HTTPS, but even with HTTP problem. You can adjust the "keepAlive" parameter to keep in touch longer, and this should speed things up.

+63
Sep 10 '14 at 12:26
source share

From the Tomcat Documentation . To block I / O (BIO), the default value of maxConnections is maxThreads if only Executor (thread pool) is used, in this case the value 'maxThreads' from Executor is used instead. For a non-blocking IO, it does not seem to depend on maxThreads .

+3
Jul 10 '14 at
source share



All Articles