java - Tomcat:当连接数超过线程数时会发生什么?

标签 java spring-boot tomcat

根据这个link ,属性 server.tomcat.max-connections 和 server.tomcat.max-threads 确定应用程序中的最大连接数和最大线程数。

我有两个问题:

  • 如果在给定时刻连接数超过线程数会发生什么?没有得到线程的连接会发生什么?
  • 如果服务器必须处理比 server.tomcat.max-connections 多的请求,会发生什么?它会忽略在线程连接数达到最大值后到达的请求吗?
  • 最佳答案

    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/

    相关文章:

    java - 在运行时测量 Java 中一段代码的内存使用情况作为服务的持续功能

    spring - 使用带有 Spring Annotations 的 ehcache 3(不使用 Spring Boot)

    eclipse - 无法在 eclipse 中解析导入 javax.jws

    tomcat - 为什么 servlet [XYZ] 在路径 [/ABC] 上下文中的 Servlet.service() 抛出异常

    java.lang.NoClassDefFoundError : Could not initialize class x 错误

    java - 如何调整ScrollView中的Banner广告

    java - 按键 : How to detect if the user pressed the "Down" arrow key on their keyboard when the app is running

    java - Mockito 不是 stub 该方法,而是调用该方法

    java - 如何在 spring boot 中连接到 MongoDB?

    java - 为什么cql查询时间很长