Skip to content
SD-11 · Back to the write-up

Design a Distributed Event Log

Partition each topic into replicated append-only logs, let consumers pull by offset, and tier old segments to object storage.

Follow a request

Producers
Cluster
Copies
Consumers
ProducerBatches + compresses
ControllerRaft quorum of 3
Leader brokerPartition 7, epoch 7
Follower brokerIn sync, other zone
Group coordinatorMembers + offsets
Object storageDays 2 to 7
Region mirrorStandby cluster
ConsumerGroup member
1producer → leader · batch seq 42The producer hashes order_id to partition 7, fills a batch of 64 events in under 5 ms, compresses it and sends it to the leader. The leader checks the sequence number, gives the batch offsets 1,205 to 1,268 and appends it to the active segment in the page cache.1 / 4

The numbers, at a glance

For every byte written……it is copied twice and read about 3 times
1 write ≈ 750 MB/s2 copies + 3 reads ≈ 3.75 GB/s
A week on broker disks64.8 TB a day with 3 copies
Most of the week leaves the brokersTiered storage keeps 1 day of 7 local
So 13 brokers are sized for throughput, not for a week of data.

A produce with acks=all, in order

The consumer only sees the batch once the high watermark passes it.

Producer
Leader
Follower A
Follower B
Consumer
1 batch, seq 42
2 fetch from 1,205
3 1,205 to 1,268
4 fetch from 1,205
5 1,205 to 1,268
6 fetch from 1,269
7 ack base 1,205
8 fetch from 1,205
9 records up to HW 1,269
RequestResponseAsync, does not block

What holds the events

The decision this question is really about.

Queue, delete on ack
Wrong shape
push to worker
ack → delete
2nd reader? copy it
+ Per-message retries.− No replay; each reader needs a copy.
Table polled by readers
Too slow
INSERT event
SELECT id > last
DELETE old rows
+ Familiar and queryable.− Index writes and deletes at 3M/s.
Partitioned log
Our pick
append to partition 7
3 copies, HW movesreaders keep offsets
drop whole segments
+ Sequential I/O, many readers, replay.− Order only per partition.

How it grows

Add a box only when a number forces you to. Highlighted boxes are new at each stage.

Stage 1 · ≈ 10 MB/sMake it work
Producers
One broker
Consumers
One broker appends to a file per topic; readers pull by offset.
Stage 2 · ≈ 300 MB/sPartition and replicate
Producers
Controller quorum
Brokers × NFollowers
Consumers
Partitions over 10 brokers, 3 copies each, a controller to pick leaders.
Stage 3 · ≈ 3 GB/sBatch and share
Batching producers
Controller quorum
Brokers × 13Followers
Group coordinatorConsumer groups
Batching cuts requests 64×; groups share 256 partitions.
Stage 4 · 3 GB/s, 7 daysKeep a week
Batching producers
Controller quorum
Brokers × 13Followers
Object storageRegion mirror
Consumer groups
1 day on disk, the rest in object storage; a mirror in region 2.
Was this walkthrough useful?Your vote tells us what to improve next.