Tomcat - maxThreads vs maxConnections [英] Tomcat - maxThreads vs maxConnections
问题描述
在Tomcat server.xml中什么是maxThreads与maxConnections
In Tomcat server.xml what is maxThreads versus maxConnections
我知道maxConnections是打开服务器的连接数
I understand that maxConnections is the amount of connections open to the server
而maxThreads是请求处理线程的最大数量
And maxThreads is the maximum number of request processing threads
但是两个配置参数如何协同工作,显然你不会将maxConnections设置为1000和maxThreads到10
But how the two configuration parameters working together, obviously you will not set maxConnections to 1000 and maxThreads to 10
两个配置参数之间有什么关系?
What is the relationship between the two configuration parameters?
<Connector
port="8443"
protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="250"
SSLEnabled="true"
scheme="https" secure="true"
clientAuth="false"
sslProtocol="TLS"
connectiontimeout="20000"
/>
推荐答案
Tomcat可以在两种模式下工作:
Tomcat can work in 2 modes:
- BIO - 阻止I / O(每个连接一个线程)
- NIO - 非阻塞I / O (比线程更多的连接)
- BIO – blocking I/O (one thread per connection)
- NIO – non-blocking I/O (many more connections than threads)
Tomcat 7 是 BIO默认情况下,虽然共识似乎是不要使用Bio,因为Nio在各方面都更好。您可以使用 协议$ c
。 server.xml
文件中的$ c>参数
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将
HTTP / 1.1
或org.apache.coyote.http11.Http11Protocol
- NIO将
org.apache.coyote.http11.Http11NioProtocol
- BIO will be
HTTP/1.1
ororg.apache.coyote.http11.Http11Protocol
- NIO will be
org.apache.coyote.http11.Http11NioProtocol
如果您正在使用BIO,那么我相信它们应该或多或少相同。
If you're using BIO then I believe they should be more or less the same.
如果您正在使用NIO,那么实际上maxConnections = 1000和maxThreads = 10甚至可能是合理的。默认值为maxConnections = 10,000,maxThreads = 200。使用NIO,每个线程可以提供任意数量的连接,来回切换但保留连接,因此您不需要进行所有通常的握手,这对于HTTPS来说尤其耗时,但即使是HTTP问题也是如此。您可以调整keepAlive参数以保持连接的时间更长,这样可以加速所有事情。
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.
这篇关于Tomcat - maxThreads vs maxConnections的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!