Interview practice question
Python Kafka consumer losing or duplicating messages
Data Engineering · Python · Experienced
Your Python Kafka consumer sometimes loses messages after a crash and sometimes processes them twice. How do you fix it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Auto-commit can commit offsets before processing finishes, causing loss.
- Disable auto-commit and commit after successful processing.
- That gives at-least-once delivery, so duplicates are still possible.
- Make processing idempotent with keys or upserts.
- Handle rebalances and poison messages with a dead-letter topic.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.