Skip to main content

High-level Architecture

Before diving into Kafka's internals, let's establish the vocabulary.

Core concepts

TermWhat it is
BrokerA Kafka server. Stores data, serves reads and writes. A cluster has multiple brokers.
RecordA single message: key + value + timestamp + optional headers
TopicA named stream of records -- like a table in a database. Identified by name, must be unique in the cluster.
ProducerAn application that publishes records to topics
ConsumerAn application that reads records from topics
Think first
Traditional message queues delete messages after they are consumed. What advantages and disadvantages would there be if a messaging system kept messages around even after consumption? Think about debugging, replaying events, and storage costs.

Topics are not queues

Unlike traditional message queues, Kafka topics retain messages after consumption. Messages stay for a configurable retention period (or until a size limit is hit). Consumers can re-read old messages at any time by resetting their offset. Kafka's performance is constant regardless of data size, so long retention is practical.

Producers and consumers are fully decoupled

Producers write without knowing who (or whether anyone) reads. Consumers read without knowing who produced. They never interact directly -- Kafka sits between them. This decoupling is what makes Kafka so flexible as an integration backbone.

Think first
If producers and consumers are fully decoupled and never interact directly, how does a consumer know where to find its messages? What component must sit in the middle, and what responsibilities does it need?

Cluster architecture

A Kafka deployment consists of:

ComponentRole
Kafka clusterOne or more brokers working together
ZooKeeperDistributed coordination service that stores cluster metadata (broker list, topic configs, partition leaders, consumer offsets). Highly optimized for reads.
ZooKeeper is being replaced

Newer Kafka versions (3.x+) introduce KRaft mode, which replaces ZooKeeper with an internal Raft-based consensus protocol. This simplifies deployment and removes the external dependency. The concepts in this course apply to both modes -- the coordination logic is the same, just managed differently.

Quiz
What would happen if Kafka deleted messages immediately after a consumer reads them, like a traditional message queue?