Try
↑ ↓ move↵ openesc close
In this lesson · topic 4 of 7
  1. 1. Why put a buffer in the middle
  2. 2. Capacity, full-queue policy and Little's law
  3. 3. Bursts against a 200-message buffer
  4. 4. Why a bigger buffer only adds delay
  5. 5. Watch the age of the oldest message
  6. 6. One slow message holds up the line
  7. 7. Sizing, waiting and dropping: three checks

Topic 4

Why a bigger buffer only adds delay

6 min read

Every number on this page was produced by the simulator with fixed seeds and is checked by a test in the repository. Where a number is an average over six seeds, the setup says so when you hover it.

Waiting climbs fast near full load

Three consumers can do 9 messages a secondmeasured together. Send them a steady, random stream at half of that, and a message waits 0.06 smeasured on average. At 80 percent of capacity the wait is 0.36 smeasured. At 95 percent it is 2.21 smeasured.

Load rose by less than half between the last two, and the wait rose several times over. Near full load there is no slack left to clear even a small random clump of arrivals. A system that looks fine at moderate load can be in trouble near full load without any change in how it works.

Sustained overload fills any buffer

Now send 12 messages a secondmeasured to the same consumers, with a queue of 40 and drop-the-newest. The consumers finish 8.96 a secondmeasured, which is their capacity. The rest, 25%measured of the traffic, is dropped.

A queue can hide a burst because the quiet time afterwards pays the debt back. Under sustained overload there is no quiet time. The buffer fills once and stays full.

A bigger buffer only adds delay

Try a queue of 200 instead. The consumers still finish 8.94 a secondmeasured, and still 24%measured of the traffic is lost. The only thing that changed is the wait. With a queue of 20, a message waits 1.9 smeasured on average. With a queue of 200 it waits 21.0 smeasured.

Little’s law explains it. A full queue holds about its capacity, and messages enter it at a rate set by how fast the consumers drain it. So the wait is close to the buffer size divided by the drain rate. Ten times the buffer gives roughly ten times the wait.

The three policies under overload

Blocking loses nothing, but the producers fall behind. With a queue of 20, the producers are holding back 360measured messages after 100 seconds and 1982measured after 600. The backlog never stops growing, because the extra work has simply moved into the producers.

Dropping the oldest and dropping the newest lose the same share of messages. They differ in which ones. With a queue of 100, the messages that dropping the newest serves waited 10.6 smeasured on average. With dropping the oldest it is 7.9 smeasured. Evicting the head keeps the queue full of recent messages, and the ones that get through are fresher.

What the average hides

Little’s law held in every run here. Even in the first minute of an overload, the two sides stayed within a few percent of each other: the ratio of L to λ W was 1.00measured after 60 seconds and 0.99measured after 1500 seconds. But it is a statement about averages. It cannot tell you the wait of the slowest one percent, or how many messages are old. For that you need to measure the age of the oldest message, not only the depth.

What the model leaves out

  • Service times are random with a fixed average. Real work has long tails and, if one message is slow, everything behind it waits.
  • Producers send at a rate that ignores the queue. Real clients slow down, or retry and send more, when they see delay. Retries can turn a small overload into a large one.
  • The queue is a single line. Real brokers may have priorities, several queues, and messages that persist to disk.
  • Consumers never fail. The next lesson is about what happens when they do.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms