A bounded queue is full and another message arrives. What are your options?
Sketch your own answer first, then compare it with the one below.
A strong answer
There are three common choices. Block the producer, so the send waits for room. Drop the newest message, which refuses the arrival. Drop the oldest, which evicts the head to make room.
Blocking loses nothing but moves the delay upstream. Dropping the newest protects the work already accepted. Dropping the oldest keeps the freshest data, which suits readings that are replaced by newer ones.
Fit the choice to the data. Orders cannot be dropped, while a position update can. Returning an error to the caller is a fourth option: it is dropping, but the caller can see it.
Sources
- Martin Kleppmann (2017). Designing Data-Intensive Applications.