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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With