Consumer lag on a 12-partition orders topic has climbed from near zero to 2 million records in an hour. There are 12 consumers, CPU sits at 30% and nothing was deployed. What do you look at first, and what would each finding tell you?
Why they ask this
Lag is the most-asked Kafka scenario. MoEngage's Kafka round went into backpressure handling, and "how do you know a consumer is falling behind" is on the compiled lists. Low CPU rules out the reflex answer and forces an actual diagnosis.
Say this
First split the lag by partition: if one or two partitions hold it, it is a hot key or a stuck consumer; if it is spread evenly, the group as a whole is slower than the input. Even lag with low CPU usually means the consumers are waiting — on the database, on rebalances or on commits — so the fix is concurrency or batching at the sink, not more pods.
The reasoning
**Shape first.** `kafka-consumer-groups.sh --bootstrap-server broker:9092 --describe --group orders-writer` gives the committed offset, log-end offset and lag for every partition, and which consumer owns it. Check the input side too: if producers suddenly doubled their rate — a backfill, an upstream retry storm — the consumers may be fine and simply outrun. Lag is arrival rate minus service rate, and either side can move.
**Uneven lag** points at one partition. A hot key shows as one partition with far more incoming bytes than the rest. A poison record shows as a committed offset that is not moving at all, with the consumer restarting in its logs. A sick instance — a bad node, long garbage-collection pauses — shows as every partition owned by that one consumer lagging together. A frozen offset and a slowly moving one are different problems.
**Even lag with idle CPU** means the consumers are blocked. The usual causes are a slow sink (look at the p99 of the write, not the average), a synchronous call per record, `commitSync()` after every record, or rebalance churn — every rebalance pauses consumption, so check the logs and the group's rebalance rate. The client metrics `records-lag-max`, `fetch-latency-avg` and `poll-idle-ratio-avg` tell you whether the consumer is waiting on Kafka or on its own processing.
The fixes follow the cause: batch and parallelise sink writes (keyed so per-order ordering holds), stop committing per record, stabilise the group with static membership or the KIP-848 protocol, fix the key. Only if all 12 consumers are genuinely busy is more parallelism the answer — and in a classic group that means more partitions. Meanwhile, work out the headroom: how many hours until the oldest unread record falls out of retention.
The answer most people give
"Add more consumers." With 12 partitions and 12 consumers, a thirteenth gets nothing. And at 30% CPU the consumers are not short of compute — they are waiting on something, and more of them would wait in parallel on the same database.
They’ll ask next
The lag is all on partition 7, and its committed offset has not moved for 20 minutes. What now?
Reported in 3 interview write-ups
