Tomcat - maxThreads vs maxConnections

前端 未结 2 1064
小鲜肉
小鲜肉 2020-11-28 01:59

In Tomcat server.xml what is maxThreads versus maxConnections

I understand that maxConnections is the number of c

相关标签:
2条回答
  • 2020-11-28 02:52

    From Tomcat documentation, For blocking I/O (BIO), the default value of maxConnections is the value of maxThreads unless Executor (thread pool) is used in which case, the value of 'maxThreads' from Executor will be used instead. For Non-blocking IO, it doesn't seem to be dependent on maxThreads.

    0 讨论(0)
  • 2020-11-28 02:57

    Tomcat can work in 2 modes:

    • BIO – blocking I/O (one thread per connection)
    • NIO – non-blocking I/O (many more connections than threads)

    Tomcat 7 is BIO by default, although consensus seems to be "don't use Bio because Nio is better in every way". You set this using the protocol parameter in the server.xml file.

    • BIO will be HTTP/1.1 or org.apache.coyote.http11.Http11Protocol
    • NIO will be org.apache.coyote.http11.Http11NioProtocol

    If you're using BIO then I believe they should be more or less the same.

    If you're using NIO then actually "maxConnections=1000" and "maxThreads=10" might even be reasonable. The defaults are maxConnections=10,000 and maxThreads=200. With NIO, each thread can serve any number of connections, switching back and forth but retaining the connection so you don't need to do all the usual handshaking which is especially time-consuming with HTTPS but even an issue with HTTP. You can adjust the "keepAlive" parameter to keep connections around for longer and this should speed everything up.

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