根据这个link ,属性 server.tomcat.max-connections 和 server.tomcat.max-threads 确定应用程序中的最大连接数和最大线程数。
我有两个问题:
最佳答案
What happens if at a given moment number of connections exceed number of threads? What will happen to the connections that did not get a thread?
他们将等待工作线程可用。
Tomcat 使用“接受队列”来保持接受它们和将它们传递给工作线程之间的连接。控制它的 Tomcat 配置参数是:
acceptCount
: 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.
(来源 https://tomcat.apache.org/tomcat-8.0-doc/config/http.html)
What happens if the server has to serve more requests than
server.tomcat.max-connections
? Will it just ignore the requests that arrived after number of threads connections has reached its maximum value?
根据上面的内容,连接将被接受到队列限制,然后被拒绝。我认为这意味着客户端将获得 TCP/IP 级别的“连接被拒绝”。
(如果客户端超时并关闭来自客户端的 TCP/IP 连接,排队的请求会发生什么情况并不完全清楚。)
关于java - Tomcat:当连接数超过线程数时会发生什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60502584/