Anton Ilinchik is author of this post on Zalando site. We all know that thread creation in Java is not free. The actual overhead varies across platforms, but thread creation takes time, introducing latency into request processing, and requires some processing activity by the JVM and OS. This is where the Thread Pool comes to the rescue.
A well-tuned thread pool can get the most out of your system and help you survive peak loads.
The post then explains:
- Why should I set a limit for my thread pool?
- How to know your limits
- Blocking coefficient and concurrency formula
- Little’s law
If you have different classes of tasks it is best practice to use multiple thread pools, so each can be tuned according to its workload.
These formulas are not a silver bullet and cannot magically fit any projects but they could be a great starting point for your project. The disadvantage of the formulas is that they focus on the average number of requests in the system and might not suit for various traffic burst patterns. Great read for anybody working with Java programming language.
[Read More]