Search code examples
javamicroservicesthreadpool

Does it make sense to have a separate microservice for thread pool in Java?


I am wondering if you can help me with this question, does it make sense to have a separate microservice that is responsible for managing threads, thread pool for a specific application? The threads that this microservice manage have to be executed in the other application code..

So this means that the Thread pool microservice lives in a different JVM, apart from the application code that lives in another JVM?

Which means more that threads are being created by JVM 1 and executed in JVM 2 for a different application..

Thank you.


Solution

  • First impression: Bad idea.


    Not a hard and fast rule, but the individual micro-services should be decoupled.

    Thread management is the job of the Operating System. So, in effect, this Thread Manager micro-service will become unofficial OS of your architecture. As a result this architecture will become a layered one instead, with thread manager being the bottom layer.

    Your micro-services should be working in the problem domain, meaning that they should be taking a unit of input (for ex: a shopping list) and returning a unit of output (for ex: purchased items off the shopping list). By making a micro-service return threads, you have broken the abstraction.