You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is the best way to handle a situation where there are not enough threads provided for all dispatchers? Here is a very simplified example with a single dispatcher:
The problem with this is that the message handler never gets invoked because the first two threads are reserved for NatsConnectionReader and NatsConnectionWriter, the dispatcher cannot obtain its thread, but no errors are ever thrown.
This issue arises with certain frameworks that use NATS, as they provide fixed-size thread pools based on the number of processors. This can make debugging difficult, as everything may work fine locally, but when deployed in an environment with a smaller number of processors, if the framework limits the pool size based on the number of processors, some dispatchers may never process messages. Additionally, from the NATS management perspective, all subscriptions appear fine.
Furthermore, with this configuration, since there is a dedicated thread for every dispatcher message handler that is allocated during the startup, if that thread gets suspended due to the framework or a library used in the implementation, no warning is ever generated. In that scenario, NatsConnectionReader will continue to push messages to the dispatcher's queue, but messages will never be picked up.
Is there a way to get an exception if a dedicated thread per dispatcher cannot be allocated during the startup, and if a message sits in a dispatcher's queue for too long?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Dear,
What is the best way to handle a situation where there are not enough threads provided for all dispatchers? Here is a very simplified example with a single dispatcher:
The problem with this is that the message handler never gets invoked because the first two threads are reserved for
NatsConnectionReader
andNatsConnectionWriter
, the dispatcher cannot obtain its thread, but no errors are ever thrown.This issue arises with certain frameworks that use NATS, as they provide fixed-size thread pools based on the number of processors. This can make debugging difficult, as everything may work fine locally, but when deployed in an environment with a smaller number of processors, if the framework limits the pool size based on the number of processors, some dispatchers may never process messages. Additionally, from the NATS management perspective, all subscriptions appear fine.
Furthermore, with this configuration, since there is a dedicated thread for every dispatcher message handler that is allocated during the startup, if that thread gets suspended due to the framework or a library used in the implementation, no warning is ever generated. In that scenario,
NatsConnectionReader
will continue to push messages to the dispatcher's queue, but messages will never be picked up.Is there a way to get an exception if a dedicated thread per dispatcher cannot be allocated during the startup, and if a message sits in a dispatcher's queue for too long?
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions