Producers write 100 messages a second to a queue that holds 1,000. The consumers finish 80 a second. How long until it is full, and what then?
Sketch your own answer first, then compare it with the one below.
A strong answer
The queue grows by the gap between the two rates: 100 minus 80 is 20 messages a second. Starting empty, it holds 1,000 after 1,000 / 20 = 50 seconds.
After that the queue is full and every extra message needs a decision. Block the producer, refuse the newest, or evict the oldest. None of these makes the consumers faster. The 20 a second that cannot be handled is still there, and it now shows up as blocked callers or dropped messages.
The useful reading is that a bigger queue only buys time. At 10,000 slots the same arithmetic gives 500 seconds, which is a longer warning and a longer wait for every message at the back. The fix is on the rate side: five more messages a second from each consumer, a fifth consumer if each does 20 a second, or less work arriving.
Sources
- Mor Harchol-Balter (2013). Performance Modeling and Design of Computer Systems.
- John D. C. Little (1961). A Proof for the Queuing Formula: L = λ W.