简体   繁体   中英

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?

Can we configure it too?

It allocate thread per request. In Spring boot the rest controllers has a default singleton scope. So there is only one instance of the rest controller. The number of threads is controlled by the number of instances of dispatcher servlet.You can observer through jconsole.

Spring Boot uses the server.tomcat.max-threads property to control the size of the client request thread pool. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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