KatInterview

Build a Fault-Tolerant Block Store for Massive Tabular Datasets

System DesignModel answer
HardModel answerSystem Designdistributed-storagereplicationmetadata

Last updated

Design a distributed block-based file store for huge structured datasets, covering versioned metadata, caching, replica repair, locality-aware job scheduling, and resource-aware balancing.

You are asked to design a distributed storage service that holds very large structured datasets and feeds batch data-processing jobs. Do not stop at a box-and-arrow diagram. Walk through concrete request flows and failure sequences.

No cluster size, data volume, or latency target is given, so state your assumptions explicitly and avoid inventing deployment facts. Begin by clarifying:

  • Are files immutable, append-only, or randomly mutable? How do jobs read them?
  • Is the load mostly large sequential scans, appends, or small random reads?
  • What durability and availability must survive a node or rack loss?
  • Do jobs run inside this service or as clients of it? How much does data locality matter?
  • Which cached data may be stale, and how is a file version identified?

Keep namespace metadata separate from large data blocks.

Part 1: Storage and cache flows. Describe how a large file is written and then read. Cover block placement, how metadata is published, and where caches sit. Address block IDs, file versions or manifests, who is the metadata authority, what a durable write acknowledgement means, how client metadata caches and block caches are invalidated or versioned, and how you keep read amplification bounded for structured (columnar or row-group) data while exploiting locality.

Part 2: Node failure and recovery. Describe failure detection, replica selection for reads, repair, and metadata availability. Cover checksums, placement across failure domains, repair prioritization, a single authoritative metadata state under failover, and how interrupted writes are cleaned up without ever exposing incomplete files.

Part 3: Jobs and load balancing. Explain how queued work is assigned and how storage and compute resources are kept balanced. Cover job and attempt identity, retries, locality-aware scheduling, output commit rules, capacity-aware placement, rebalancing under bandwidth limits, backpressure, and metrics that distinguish metadata, disk, network, and worker bottlenecks.

Hints

Hint 1

Pick a workload model first: write-once, large, mostly sequential files with optional append is a good default. It lets you make files immutable per version, which simplifies caching and replication.

Hint 2

Treat the file as a manifest (an ordered list of block IDs with checksums) published atomically by a replicated metadata service. Data is invisible until the manifest commit, which solves both interrupted writes and cache consistency.

Hint 3

For jobs, give every task a stable ID and each execution an attempt ID. Attempts write to private temporary paths, and only a single commit step promotes one winning attempt's output via the same atomic manifest publish.

Hint 4

Separate the failure story into detection (heartbeats, checksum mismatch), prioritization (fewest surviving replicas first), and throttling (repair and rebalance traffic must not starve foreground reads).