Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 关于SpringBoot Tomcat acceptCount池_Java_Spring_Spring Boot_Tomcat_Configuration - Fatal编程技术网

Java 关于SpringBoot Tomcat acceptCount池

Java 关于SpringBoot Tomcat acceptCount池,java,spring,spring-boot,tomcat,configuration,Java,Spring,Spring Boot,Tomcat,Configuration,我正在处理springboot上的Tomcat配置 让我们假设我有以下配置: server: tomcat: min-spare-threads: ${min-tomcat-threads:20} max-threads: ${max-tomcat-threads:20} accept-count: ${accept-concurrent-queue:1} max-connections: ${max-tomcat-connections:100} 我有一个

我正在处理springboot上的Tomcat配置

让我们假设我有以下配置:

server:
  tomcat:
    min-spare-threads: ${min-tomcat-threads:20}
    max-threads: ${max-tomcat-threads:20}
    accept-count: ${accept-concurrent-queue:1}
    max-connections: ${max-tomcat-connections:100}
我有一个简单的RestController,代码如下:

    public String request(@Valid @RequestBody Info info) {
        
        log.info("Thread sleeping");
          
        Thread.sleep(8000);
        
        return "OK";

    }
然后我做了以下测试:

  • 我每秒发送200个HTTP请求
  • 我检查了日志,正如我预期的那样,我看到100次同时执行,8秒后我看到最后一次(排队)
  • 其他处决被拒绝
  • 我遇到的主要问题是,如果我对客户端调用有超时控制(例如,5秒),那么排队的操作无论如何都会在服务器上处理,即使它在客户端被拒绝。 我想避免这种情况,所以我尝试:

    server:
      tomcat:
        min-spare-threads: ${min-tomcat-threads:20}
        max-threads: ${max-tomcat-threads:20}
        accept-count: ${accept-concurrent-queue:0}
        max-connections: ${max-tomcat-connections:100}
    
    但是这个“0”被完全忽略了(我认为在这个例子中它的意思是“无限”)。 所以,我的问题是: ?如果达到最大连接数限制,是否可以将Tomcat配置为不排队操作? 或许 ?是否可以将Tomcat配置为拒绝任何排队的操作

    事先非常感谢

    致以最诚挚的问候。

    该参数的值直接传递给操作系统:例如,对于UNIX es,它被传递给
    listen
    。由于传入连接总是在JVM接受它之前放入OS队列,因此低于
    1
    的值没有意义。Tomcat显式忽略这些值,并保留其默认值
    100

    但是,Tomcat中真正的队列是从OS队列接受的连接,但由于缺少处理线程(
    maxThreads
    )而未被处理。您最多可以有
    maxConnections-maxThreads+1
    这样的连接。在您的情况下,有81个连接等待处理