Back to portfolio
Distributed systemsKafkaArchitecture

Kafka architecture, explained from the original paper

Kafka is best understood as a distributed, partitioned, append-only log. Producers write events, brokers store them, and consumers pull at their own pace using offsets.

Interactive model

Producers append to partition logs

Events are batched and written sequentially. Kafka leans into append-only disk access instead of random queue mutation.

topicpageviews
parallelism3 partitions
deliverypull + offsets
events appended12
next appendp0
Producer API
Batch send
Partition key
Broker 1
p0

offset

0

offset

215

offset

430

offset

645

consumer bookmark215
ownerMetrics A
Broker 2
p1

offset

0

offset

188

offset

376

offset

564

consumer bookmark188
ownerMetrics B
Broker 3
p2

offset

0

offset

204

offset

408

offset

612

consumer bookmark204
ownerMetrics C
Real-time metrics group

own offset, same topic

Warehouse loader group

own offset, same topic

01

The core model: topics split into partitions

A Kafka topic is a named event stream, such as pageviews or clicks. Kafka splits each topic into partitions so data can be spread across brokers and consumed in parallel.

Topic: pageviews
Partition 0 on Broker 1
Partition 1 on Broker 2
Partition 2 on Broker 3

This is the main scaling lever. More partitions allow more brokers to store data and more consumers to process data. Kafka preserves order within a partition, not across the entire topic.

02

Each partition is an append-only log

Producers append messages to the end of a partition. Each message is addressed by an offset, which is just its logical position in the log.

offset 0

message A

offset 215

message B

offset 430

message C

offset 645

message D

Consumer bookmark: resume from offset 430

This design avoids heavy per-message indexes. It also makes replay natural: a consumer can move its offset backward and read the same data again.

03

Consumers pull data in groups

Kafka does not push messages to consumers. Consumers ask brokers for records from a specific offset and fetch batches of data.

Consumer group: real-time metrics

Partition 0 -> Consumer A
Partition 1 -> Consumer B
Partition 2 -> Consumer C

Consumer group: warehouse loader

Reads the same topic independently
Keeps its own offsets
Can lag behind without blocking others

Within a group, a partition is owned by one consumer at a time. That keeps ordering simple and avoids locking between consumers. Different groups can read the same stream independently.

04

Why the broker is intentionally simple

Kafka brokers store bytes and serve fetch requests. They do not track every consumer's delivery state. In the original design, consumer offsets and partition ownership were coordinated through ZooKeeper.

Page cache

Kafka relies on the operating system page cache instead of duplicating data in broker memory.

sendfile

Brokers can move bytes from disk to socket with fewer copies.

Retention

Messages are kept for a time window, so consumers can replay old data.

05

Deployment pattern from the paper

LinkedIn ran Kafka clusters in live datacenters for real-time consumers, then copied streams to an analysis datacenter near Hadoop and the data warehouse.

Frontend services
Local Kafka cluster
Hadoop and warehouse

The result was one pipeline for online and offline consumers, with about 10 seconds of end-to-end latency in their production setup.

Takeaway

The design choice behind the architecture

Kafka became fast because it narrowed the problem. It traded heavyweight queue semantics for append-only logs, batched I/O, pull-based reads, consumer-managed offsets, and partition-level parallelism.

The architecture is not just a broker cluster. It is a storage model: durable streams with independent bookmarks for every consumer group.