Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing
Back
  1. Home
  2. Interview prep
  3. Producer, Broker, Consumer, Topic, Partition

Kafka · Core Concepts

Producer, Broker, Consumer, Topic, Partition

Easykafka-02
producerbrokerconsumertopicpartitionbasics

Question

Explain Producer, Broker, Consumer, Topic, and Partition in Kafka.

Solution

These five terms are the vocabulary every Kafka interview starts with.

Producer

An app that writes events into Kafka. Think orders service, clickstream collector, CDC connector.

Broker

One Kafka server process. It stores partition logs on disk and serves produce/fetch requests. A cluster is multiple brokers working together.

Consumer

An app that reads events from Kafka. Think fraud detector, warehouse loader, search indexer.

Topic

A named stream of related events, like orders or page_views. Producers write to topics; consumers subscribe to topics.

Partition

A topic is split into partitions. Each partition is an append-only, ordered log. That split is how Kafka scales and parallelizes.

                 produce                         fetch                  Producer  ----------------->  Broker(s)  <----------------  Consumer                                   |                                                              topic: orders                                                      ┌─────────┼─────────┐                                                 ↓         ↓         ↓                                              part 0    part 1    part 2                                            [m0 m1]   [m0 m1]   [m0]                        

How they fit together

1. Producer sends a record to a topic. 2. Kafka places it in a partition (by key or round-robin). 3. The record is stored on a broker (and usually replicated). 4. A consumer reads from that partition using an offset.

Interview tip: "Topic = category of events; partition = ordered shard; broker = server; producer writes; consumer reads."

PreviousNext