Tech challenge · Kafka

Consumer lag keeps growing

MediumKafka

A consumer group reading a 6-partition topic falls further behind every hour. You scaled the group from 6 to 12 consumers and lag did not improve. Why, and what would you look at next?

Think it through or sketch an answer first, then open the hint or the solution.

Show a hint

How many consumers in one group can read a partition at the same time?

Show the solution

Within a group, each partition is read by at most one consumer, so with 6 partitions the extra 6 consumers sit idle. Find where time goes in the consumer: usually slow per-record processing or a slow sink. Process in batches, write to the sink in bulk, and only then consider more partitions (planned, because keys are remapped). Watch lag per partition: one lagging partition points to skew or a stuck consumer.

Common mistakes

  • Adding consumers beyond the partition count.
  • Setting a very long max.poll.interval.ms to hide slow processing, which delays detection of stuck consumers.

Learn more

More Kafka challenges

Today's challenge and the full archive