I am developing application server using spring boot app but now I want to know what is the default maximum (client request) thread pool size in spring and how can I customize that value?
Starting thread pool size is 1, core pool size is 5, max pool size is 10 and the queue is 100. As requests come in, threads will be created up to 5 and then tasks will be added to the queue until it reaches 100. When the queue is full new threads will be created up to maxPoolSize .
Maximum number of threads in Spring Boot Application If you are using Tomcat as your embedded server (default), then you can use the property server. tomcat. max-threads to control how many threads you want to allow. This is set to 0 by default which means- use the Tomcat default which is 200 .
To handle high traffic, you should setup Load Balancer with multiple node/instances. Better to go with Auto Scaling on Cloud server. It will increase the instances as per high load (number or request) and again decrease the instances when there will be low number of requests. Which is cost effective.
Assuming that you're using embedded Tomcat, 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
file.
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