Explain the Kafka message flow end-to-end
A crisp walkthrough of what happens between a producer's `send()` call and a consumer's `poll()` receiving the message.
Question
Walk me through what happens when a Kafka producer sends a message and a consumer receives it.
Answer
1) The **producer** serializes the message and computes a partition — usually `hash(key) % partitions` (or round-robin if no key). 2) It sends the record to the **broker that owns the leader replica** of that partition; the broker appends the record to its local log, replicates it to follower brokers, and (based on `acks`) returns an offset. 3) The record now sits at that offset in the partition, immutable. 4) A **consumer** in a consumer group is assigned that partition by the group coordinator, tracks its position via a **committed offset** (stored in the internal `__consumer_offsets` topic), and calls `poll()`. 5) Kafka returns a batch of records starting at that offset; the consumer processes them, then commits the new offset — either automatically or explicitly. If the consumer crashes before commit, another consumer in the group picks up from the last committed offset and reprocesses.
See the question and answer above.
Keep reading
You may also like
interview
AWS: When would you pick S3 over EBS?
The right answer shows you understand *access patterns*, not just storage products.
interview
How does Terraform know what already exists?
The most missed Terraform interview follow-up. Explain state files and how they work.
interview
Explain the CAP Theorem in one paragraph
A distributed-systems classic that trips senior engineers as often as juniors.
Discussion (0)
No comments yet. Be the first to weigh in.