centiservice / mats3

Mats3: Message-based Asynchronous Transactional Staged Stateless Services
https://mats3.io/
Other
63 stars 7 forks source link

Dynamically scale concurrency based on load #26

Open stolsvik opened 5 years ago

stolsvik commented 5 years ago

A problem with the current solution/implementation, is that the concurrency is static. You set a number, and this many threads will be created for each stage of each endpoint (can be configured individually, though), each sitting with their own JMS Consumer. This number would typically be the default for the MatsFactory, hence you get '2 x cpus' x 2 (due to the dedicated interactive threads) on every single stage. The problem is that you will end up with potentially very many threads, even on endpoints that get one message per hour, or on endpoints which are very fast, where both situations could have been handled with a single thread.

If we could monitor a number that indicated load, backlog or whatever, we could scale up when there were need, and scale back down when the queues were empty.

Deduced locally:

Needs external deduction, AFAIK: