Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 248
Harshana Avatar asked Apr 16 '26 15:04

Harshana


1 Answers

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

like image 170
Pankaj Pandey Avatar answered Apr 19 '26 05:04

Pankaj Pandey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!