elizarov
03/15/2017, 8:07 PMIncCounter
very often, but one of the subscribers is very slow. You can try it. You'll quickly run out of memory, because you launch
new coroutine to send a message to each of your subscribers and, for the case of slow subscriber, they'll all just wait, consuming memory. A more scalable/reliable solution is to turn sendCounterUpdate
into supend fun
and remove launch
from inside of it. Just send to each of the subscribers. This solution will properly propagate backpressure from the slow consumer to the original sender, making it scale to very high loads without exhausting resources.