Free preview

Storage: Why Local Disk and Not a Blob Store

Why this matters: "why not just use S3?" is a question interviewers genuinely ask, and the answer here is one of the few places in system design where spinning-disk physics is the deciding argument.

Key takeaway

Blob stores like S3 are not optimized for writing or reading small amounts of data, and geo-replication exacerbates the problem. The design instead uses the server's local persistent store with append-based writing.

Why not a blob store?

"Why can't we use blob stores like S3 to keep messages, instead of the broker's local storage?"

Blob stores like S3 are not optimized for writing or reading small amounts of data. If our data is geo-replicated, the above problem is exacerbated.

Therefore, we used the server's local persistent store with append-based writing. Traditional hard disks are specifically tuned to deliver good write performance when writing to contiguous tracks or sectors. Reading throughput and latency is also good for contiguous regions of the disk because it allows extensive data caching.

Blob store (S3)Local disk, append-only
Optimized forLarge objects, infrequently accessedSmall records, written and read constantly
Per-operation costAn HTTP round trip per object — dominates when the object is 1 KBAn append to an open file, often just a page-cache write
Access patternRandom object addressingContiguous tracks and sectors — the pattern disks are tuned for
CachingRemote; limited benefitExtensive — contiguous regions cache well
Geo-replicationMakes it worse — every small operation crosses regionsReplication is broker-to-broker, batched

Spreading partitions across brokers

"What problems can arise if all partitions are on the same broker?"

If the broker fails or dies, all the messages in the partitions will be lost. To avoid this, we need to ensure the partitions are spread across different brokers.

Partitions are distributed across different brokers in the cluster.

Two views of the same thing, both worth being able to draw:

  • Physical view: a broker contains multiple topics, and a topic's partitions are spread across other brokers.
  • Logical view: topic B is split into partitions 0, 1, 2 … n, which the consumer reasons about without caring which broker holds each.

Making messages findable

"If we use a round robin algorithm to send messages to a partition, how does the system know where to look when it is time to read?"

The system will need to persist appropriate metadata. This metadata will keep mappings between the logical index of segment or messages to the server identity or partition identifier.

The consumer manager (Lesson 10) holds this information.

Key takeaway

Small messages plus high per-operation cost is why blob stores lose here; append-only writes to contiguous disk is the one pattern disks are fastest at. Spreading partitions across brokers contains failure but does not survive it. And round-robin placement forces a metadata mapping from logical index to physical location.

Interview signal by level

LevelWhat a strong answer sounds like
L4"Messages are stored on the broker's disk."
L5Explains the pattern: "append-only writes to local disk, because sequential writes to contiguous regions are far faster than random ones, and blob stores aren't built for constant small reads and writes."
Staff+Generalizes and states the cost: "messages are capped at 1 MB, so per-operation overhead dominates — an HTTP round trip to move a kilobyte is the same mistake as not pipelining Redis. The trade is that storage is bounded by broker disk and durability becomes ours, which is why tiered storage into object storage for cold segments is where these systems are heading. And spreading partitions contains a broker failure; it doesn't survive one — that's replication's job."

Next: replication and what happens when a broker dies.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue