Try
↑ ↓ move↵ openesc close

Interview prep / Partitioned logs

Senior · Partitioned logs · System design interview question

A consumer lag alert fires. The consumers look healthy and CPU is low. How do you investigate?

Sketch your own answer first, then compare it with the one below.

A strong answer

Lag as a single number hides where it sits. First, look per partition. If one partition carries all of the lag and the others are at zero, it is a hot key or a stuck message, and more consumers would not help. Find the key and check the partitioner.

If lag is spread out and the group is rebalancing repeatedly, the cause is usually a consumer taking longer than the poll interval (five minutes by default in the Java client), which gets it evicted. The signs are many rebalance events and offsets that move backwards. A slow downstream call inside the loop is the usual reason, and the fix is smaller batches or a longer interval.

If consumers are idle and lag still grows, check whether they own partitions at all. More members than partitions leaves some idle. Check producers too: a rate jump looks like consumer lag.

Last, compare lag with the retention window. If lag is approaching it, data is about to be deleted unread. That sets the urgency. I would also graph time lag, not just message count.

Sources

Learn it by running it

The partitioned logs lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

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