简体   繁体   English

Spring启动请求和线程分配

[英]Spring boot request and thread allocation

When invoking a REST controller in a spring boot environment, it allocates thread per request or thread per connection?在 Spring Boot 环境中调用 REST 控制器时,它是按请求分配线程还是按连接分配线程?

Can we configure it too?我们也可以配置吗?

It allocate thread per request.它为每个请求分配线程。 In Spring boot the rest controllers has a default singleton scope.在 Spring Boot 中,其余控制器具有默认的单例作用域。 So there is only one instance of the rest controller.所以只有一个rest控制器的实例。 The number of threads is controlled by the number of instances of dispatcher servlet.You can observer through jconsole.线程数由dispatcher servlet的实例数控制。可以通过jconsole来观察。

Spring Boot uses the server.tomcat.max-threads property to control the size of the client request thread pool. Spring Boot 使用 server.tomcat.max-threads 属性来控制客户端请求线程池的大小。 Its default value is zero which leaves Tomcat to use its default of 200. To customise the size of this thread pool you should specify a non-zero value for the server.tomcat.max-threads property in your application.properties or application.yml它的默认值为零,这让 Tomcat 使用其默认值 200。要自定义此线程池的大小,您应该在 application.properties 或 application.yml 中为 server.tomcat.max-threads 属性指定一个非零值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM