Kafka consumer lag is growing and the topic retention is 24 hours. You're close to losing messages. What do you do?
IntermediateScenarioData and databases
Answer
Situation read → If lag reaches the retention window, unread messages are deleted. Buy time first, then catch up.
What I'd do →
- Check how close you are:
kafka-consumer-groups.sh --bootstrap-server b-1.kafka:9092 --describe --group order-processor
- Buy time: increase topic retention temporarily (check broker disk first).
kafka-configs.sh --bootstrap-server b-1.kafka:9092 --alter --entity-type topics \
--entity-name orders --add-config retention.ms=259200000
- Scale consumers up to the partition count; more consumers than partitions sit idle.
- Find why it's slow: a slow downstream (DB), a poison message causing retries, or a recent consumer change. Send poison messages to a dead-letter topic.
- Long term: alert on lag (and on time lag, not just message count), autoscale with KEDA on lag, and size partitions for peak.
Why → Extending retention protects the data while you fix throughput.
Interview tip → Mention that consumers are capped by partition count; it's the classic scaling ceiling.
More on Data and databases
A release needs to rename a column that the running app reads and writes. How do you do it with zero downtime?IntermediateHow do you prove your database backups actually work?IntermediateDesign backups for an RDS PostgreSQL database with RPO of 5 minutes and RTO of 1 hour, including a region failure.AdvancedYour migrations run in an init container and two pods ran them at the same time during a deploy, leaving the schema half-applied. How do you fix the approach?IntermediateUpgrade RDS PostgreSQL from 13 to 17 with minimal downtime. How?AdvancedYou need to add an index and a column to a 500-million-row table that's written to constantly. How do you avoid locking it?Advanced