KatInterview

Architect a Scalable Storage Cluster for Huge Files Across Many Machines

System DesignModel answer
MediumModel answerSystem Designdistributed-systemsstoragereplication

Last updated

Design a cluster-based file storage system from a vague prompt, defining workload, guarantees and scale first, then covering metadata, data placement, I/O paths and failure handling.

You are asked to design a distributed file system: a storage service that spreads files across many commodity machines and presents them to clients as a single namespace.

The prompt is deliberately short. No workload, scale or guarantees are given, so part of the task is to decide and justify them yourself before you design.

Cover the following in your answer:

  1. Scoping. Which questions would you ask, and which assumptions would you commit to? Think about:
    • The dominant workload: a modest number of very large files read and appended in bulk, or a huge number of small files with random access.
    • The semantics: full POSIX (in-place overwrites, rename, locking) or a simpler write-once / append-only model.
    • Scale: total bytes, number of files, number of concurrent clients.
    • Durability and availability goals, and which failures must be tolerated (disk, machine, rack, data center).
    • Consistency expectations for reads after writes and for directory operations such as rename.
  2. Architecture. How do you separate the metadata layer from the data layer, and how does each scale and stay available?
  3. Data placement. Block size, replication versus erasure coding, and awareness of failure domains.
  4. Read, write and append paths, including how concurrent writers are coordinated and what clients observe.
  5. Failure handling. Failure detection, restoring lost redundancy, integrity checking, and recovery from a failed metadata node.
  6. Operations. Many small files, rebalancing, reclaiming space from deleted data, and monitoring.

Be explicit about trade-offs and tie each major decision back to the requirements you chose.

Hints

Hint 1

Start by committing to a workload. Large, mostly sequential files with append-heavy writes lead to very different choices (big blocks, relaxed semantics) than a general-purpose POSIX file system.

Hint 2

Keep the metadata path separate from the data path: a small, strongly consistent service decides where blocks live, while clients stream bytes directly to and from storage nodes so the metadata service never carries bulk traffic.

Hint 3

Ask what happens when each component dies: a storage node, a whole rack, the metadata leader. For each, say how it is detected, what is repaired, and what the client sees in the meantime.

Hint 4

Estimate metadata memory: number of files and blocks multiplied by roughly 100-200 bytes each tells you when a single metadata node stops being enough and the namespace must be partitioned.