Everyone thinks a file system is a tree of directories and some inodes pointing at disk blocks. Then the interviewer says “now the files are petabytes, they do not fit on one machine, and the machines are cheap boxes that die every day,” and the easy mental model falls apart. You cannot store a 10 TB file on a 4 TB disk. You cannot survive a disk failure if there is only one copy. And the instant you spread one file across a thousand disks, you have a new problem that did not exist before: where did I put the pieces, and who still has them after three of those thousand machines caught fire overnight?

A distributed file system (GFS, HDFS, Colossus, and their descendants) solves this with one core idea: split every file into fixed-size chunks, store each chunk as an ordinary file on many commodity data nodes, replicate each chunk a few times, and keep a central index of which node holds which chunk. The index lives on a name node. That design is clean until you look hard at two things, which are exactly where the interview goes: (1) the name node is a single brain that every operation consults, so how do you stop it from becoming the bottleneck and the single point of failure, and (2) when a data node dies, the chunks it held are now under-replicated, so how does background re-replication kick in fast enough to rebuild the lost copies before a second failure loses data for good - without those rebuild transfers stealing bandwidth from live client writes.

Let me do it properly.

Functional Requirements (FR)

In scope:

  • Create / read / write / delete files organized in a hierarchical namespace (directories, paths like /logs/2026/11/app.log).
  • Large files, split into fixed-size chunks. A file is a sequence of chunks (say 64 MB or 128 MB each). Chunks are the unit of placement, replication, and recovery.
  • Append-heavy writes. The dominant write pattern is appending to a file (log ingestion, data pipelines) and writing new files whole. Random in-place overwrites are rare and we do not optimize for them.
  • Replication for durability and availability. Each chunk is stored on R nodes (default R=3). Losing up to R-1 copies must not lose data, and reads should keep working.
  • Automatic failure recovery. When a data node dies or a disk goes bad, the system detects it and re-replicates the affected chunks back up to R copies in the background, automatically, with no operator action.
  • Sequential read throughput. Readers stream large chunks at high bandwidth. Optimize for throughput, not for tiny low-latency random reads.
  • Metadata operations: list directory, stat a file (size, chunk list), rename, mkdir.

Explicitly out of scope (say this out loud so you own the scope):

  • POSIX semantics / mutable random writes. We are not building ext4 over the network. No fine-grained byte-level overwrite consistency, no mmap, no hard links. This is a write-once / append-mostly bulk store, which is what GFS and HDFS actually are.
  • Low-latency small-file workloads. Millions of tiny files are a known anti-pattern here (they blow up name node metadata). We target large files; small-file handling is a separate layer (packing into larger containers).
  • Strong cross-file transactions. No multi-file ACID transactions. Atomicity is at the single-file or single-append granularity.
  • Full POSIX permissions / rich ACLs. We assume basic ownership and permission bits, not a complete security model. Multi-tenant isolation is an add-on.

The one decision that drives everything: metadata and data travel on separate paths. Clients talk to the name node only to find out where the chunks are, then stream the actual bytes directly to and from the data nodes. The name node never touches file data. If you forget this and route data through the name node, the whole design collapses under its bandwidth - so keep the control plane (metadata, tiny and frequent) strictly separate from the data plane (bytes, huge and direct).

Non-Functional Requirements (NFR)

  • Scale: petabyte-to-exabyte total capacity. Thousands of data nodes, tens of millions to a few hundred million chunks, files ranging from hundreds of MB to multiple TB. A single name node must hold the metadata for the entire namespace in RAM.
  • Throughput over latency: optimized for high aggregate sequential throughput (tens to hundreds of GB/s cluster-wide), not for single-op latency. A metadata op (open/stat) should be a few ms; a data read is bounded by disk/network, not by us.
  • Availability: 99.99%+ for reads and writes. Individual data node failures are routine (expected daily at this scale) and must be invisible to clients. Name node failover must complete in seconds to low tens of seconds.
  • Durability: very high (11 nines territory). This is the headline property. With R=3 replicas plus fast re-replication and rack-aware placement, the probability of losing all copies of any chunk must be vanishingly small. Data loss is the one unforgivable failure.
  • Consistency: relaxed and well-defined, not linearizable. Namespace operations (create, rename, delete) are atomic and strongly consistent because they go through the single name node. File data consistency is weaker: after a successful write all replicas hold the same bytes (“defined” regions); concurrent appends may produce duplicated or padded records, which clients handle with record checksums and dedup. We choose this relaxed model deliberately for throughput.

Back-of-the-Envelope Estimation (BoE)

Let me ground the design in numbers so the bottlenecks are concrete.

Capacity and chunk count:

Total logical data stored:    10 PB  (10 * 10^15 bytes)
Replication factor:           R = 3
Raw physical data:            30 PB

Chunk size:                   128 MB
Logical chunks:               10 PB / 128 MB
                            = 10e15 / 128e6  = ~78 million chunks
Physical chunk replicas:      78M * 3        = ~234 million replicas on disk

Data node fleet:

Disk per data node:           12 disks * 10 TB = 120 TB raw per node
Usable (leave headroom ~80%): ~96 TB per node
Nodes to hold 30 PB raw:      30 PB / 96 TB    = ~320 nodes
Round up for headroom, growth,
hot spots, rebuild slack:     ~500 data nodes

Name node metadata footprint (the make-or-break number):

Per chunk, name node stores:
  chunk_id (8B) + file mapping + version + replica location list (~3 * node_id)
  ~ 150-200 bytes of in-RAM metadata per chunk (blended).

78M chunks * ~175 bytes       = ~13.7 GB of chunk metadata.

Per file/inode metadata:
  Say 5M files * ~300 bytes    = ~1.5 GB for the namespace tree + per-file info.

Total name node RAM for metadata: ~15 GB  (fits comfortably in one big box).

That ~15 GB is the whole reason a single name node is viable: the entire index of a 10 PB cluster fits in the RAM of one machine. Scale it to 1 EB and metadata is ~1.5 TB, which no longer fits - that is the point where you must federate the namespace. Remember this number; it reappears in the deep dive.

Throughput / QPS split:

Read:write ratio:             ~ 4:1 (analytics/pipeline reads dominate)

Client ops that hit the NAME NODE (metadata only - open/create/locate):
  Say 50,000 metadata ops/sec at peak across the cluster.
  Each is a tiny RPC (path -> chunk handles + locations). Cheap individually.

Data transfer that hits DATA NODES directly (never the name node):
  Aggregate read bandwidth: say 100 GB/sec cluster-wide.
  Spread over 500 nodes = ~200 MB/sec/node. Fine on 10GbE+ NICs.

The split is the whole story: 50K metadata ops/sec on one name node is survivable only because each op is tiny and data bytes never pass through it. If data went through the name node, 100 GB/sec would vaporize any single machine. Control plane small and centralized; data plane huge and direct.

Re-replication load after a node dies (the hard-part number):

One data node holds ~96 TB usable / 128 MB = ~750,000 chunk replicas.
When it dies, ~750K chunk replicas drop from R=3 to R=2.

To restore all of them to R=3, the cluster must copy ~750K chunks
(~96 TB of data) from surviving replicas to new homes.

If rebuild bandwidth is capped at, say, 40 Gbps aggregate spread
across source nodes:
  96 TB / (40 Gbps = 5 GB/s) = ~19,200 s = ~5.3 hours to fully heal.

But the recovery reads come from MANY sources in parallel (every
surviving node holding one of the lost chunks' peers), so real GFS/HDFS
clusters spread this and heal the most-urgent (R=1) chunks in minutes.

Two insights fall out of that number. First, re-replication of a full node is terabytes of traffic - if you let it run flat-out it will starve live client writes, so it must be rate-limited and prioritized. Second, the danger window is the time a chunk spends under-replicated: a second failure during those hours can take a chunk to zero copies. Minimizing time-to-repair for the most-under-replicated chunks is the core durability lever, and it is why recovery is prioritized rather than FIFO.

High-Level Design (HLD)

The architecture has three roles: one logical name node (the metadata brain and coordinator), many data nodes (commodity boxes that store chunk replicas on local disk), and a client library that talks to both. Metadata flows through the name node; file bytes flow directly between client and data nodes.

                          ┌──────────────────────────────┐
                          │          CLIENT LIB           │
                          │  open/create/stat -> NameNode │
                          │  read/write bytes -> DataNodes│
                          └──────┬────────────────┬───────┘
             (1) metadata RPC:   │                │  (3) stream bytes DIRECT
             path -> chunk ids   │                │      to/from data nodes
             + replica locations │                │      (name node NOT in path)
                          ┌───────▼──────────┐     │
                          │    NAME NODE      │     │
                          │  (metadata brain) │     │
                          │  - namespace tree │     │
                          │  - file->chunks   │     │
                          │  - chunk->nodes   │     │
                          │  - lease manager  │     │
                          │  - replication mgr│     │
                          └───┬───────────┬───┘     │
             (2) heartbeats + │           │ edit log │
                 block reports│           │ to disk  │
                 from data    │     ┌─────▼─────┐     │
                 nodes        │     │  Edit Log  │     │
                              │     │ + FsImage  │     │
                              │     │ (durable)  │     │
                              │     └────────────┘     │
         ┌────────────────────┼────────────────────────┼────────────┐
         │                    │                         │            │
   ┌─────▼──────┐      ┌───────▼─────┐           ┌───────▼─────┐  ┌───▼────────┐
   │ Data Node 1│      │ Data Node 2 │   ...     │ Data Node N │  │ Data Node M│
   │ chunks on  │◄────►│ chunks on   │◄─────────►│ chunks on   │  │ chunks on  │
   │ local disk │ repl │ local disk  │  pipeline │ local disk  │  │ local disk │
   │ heartbeat  │ ─────┤ heartbeat   │  ─────────┤ heartbeat   │  │ heartbeat  │
   └────────────┘      └─────────────┘           └─────────────┘  └────────────┘

   Standby NameNode (hot) tails the edit log for fast failover:
   ┌───────────────────────────────────────────────────────────┐
   │ STANDBY NAME NODE  - replays shared edit log, holds a warm  │
   │ copy of all metadata, promoted on primary failure (seconds) │
   └───────────────────────────────────────────────────────────┘

Request flow - reading a file (the common path):

  1. Client calls open("/logs/app.log"). The client library sends a metadata RPC to the name node.
  2. Name node resolves the path in its in-RAM namespace tree, finds the ordered list of chunk IDs for the file, and for each chunk returns the list of data nodes currently holding a replica (sorted by network proximity to the client). This is a small response - a few handles and IP addresses.
  3. The client caches this map and streams bytes directly from the nearest data node for each chunk. The name node is now out of the loop entirely; it never sees a byte of file data.
  4. If a chosen data node is slow or dead mid-read, the client transparently retries the next replica in the list. Each chunk replica carries a checksum so the client detects and rejects corrupt data.

Request flow - writing (appending to) a file:

  1. Client calls create or append. The name node allocates a new chunk ID (for a fresh chunk), chooses R data nodes to hold it using rack-aware placement, grants a lease to one of them designated the primary replica for that chunk, and returns the replica list + primary to the client.
  2. The client pushes the data to the replicas in a pipeline: it sends bytes to the nearest replica, which forwards to the next, which forwards to the third, so the client’s uplink is used once and inter-node links do the fan-out. Data is buffered on each node but not yet committed.
  3. Once all replicas have the bytes buffered, the client sends a commit/write request to the primary. The primary assigns a serial order to this mutation (and to any concurrent ones), applies it locally, and tells the secondaries to apply it in that same order.
  4. Secondaries apply and ack the primary; the primary acks the client. If any replica fails to ack, the client retries; the name node will notice the under-replicated chunk via block reports and re-replicate. The lease serializes all writers to a chunk through one primary, giving a single consistent mutation order.
  5. On a successful write the name node records the new chunk’s existence and length (committed via the edit log). File data lives on the data nodes; the name node only tracks the mapping and lengths.

The continuous background plane (not triggered by any client):

  • Every data node sends a heartbeat to the name node every few seconds (“I am alive, here is my free space and load”) and periodically a block report (the full list of chunk replicas it currently holds on disk).
  • The name node uses heartbeats to detect dead nodes (missed heartbeats past a threshold) and block reports to reconcile its chunk-to-node map against ground truth (catching silent disk loss, corruption, extra copies).
  • When the name node sees a chunk below R replicas, its replication manager schedules re-replication: pick a source that has a copy, pick a target with space on a different rack, tell the source to copy the chunk to the target. Prioritized by how under-replicated the chunk is.

The architectural spine: the name node is an index and a scheduler, never a data pipe. Everything in the deep dive is about keeping that single index fast, durable, and highly available, and keeping the background healing aggressive enough for durability but polite enough not to starve clients.

Component Deep Dive

The hard parts, each walked from naive to scalable: (1) keeping the central name node from becoming the bottleneck, (2) name node high availability (it is also a single point of failure), (3) chunk placement and the write pipeline, and (4) failure detection plus fast, non-disruptive background re-replication.

1. The Name Node Bottleneck: One Brain for the Whole Cluster

A single name node indexing the entire namespace is the defining choice of this architecture - and the obvious objection. One machine answering for a 10 PB, 500-node cluster sounds absurd until you separate what it does from what it does not do.

Naive fear: “the name node will be overwhelmed by all the I/O”

The instinct is that every read and write of a petabyte-scale cluster funneling through one box must melt it. Why that fear is misplaced - if you design the paths right: the name node handles metadata only. A client read is one small RPC (“where is /logs/app.log?”) that returns a list of chunk locations; then gigabytes of actual data stream directly between the client and data nodes, never through the name node. From the BoE: ~50K tiny metadata ops/sec is nothing for an in-RAM index, while the 100 GB/sec of data traffic the name node never touches. The separation of control plane from data plane is what makes one brain viable.

So the real bottlenecks are not bandwidth. They are three subtler things, and each has a specific fix.

(a) Metadata must fit in RAM, and stay there. The name node keeps the entire namespace tree and the chunk map in memory so lookups are microseconds, not disk seeks. From the BoE, 10 PB is ~15 GB of metadata - fine. But metadata grows with the number of files and chunks, not with bytes stored. A cluster full of tiny 1 KB files would have billions of inodes and chunks and blow past RAM. This is the famous small-files problem. Fixes: keep chunks large (128 MB) so chunk count stays low; push back on tiny files by packing them into larger container files (HAR archives, SequenceFiles) at the application layer; and when metadata genuinely outgrows one box, federate the namespace (below).

(b) The lock on the namespace. Mutations to the namespace tree (create, rename, delete, mkdir) must be serialized to stay consistent. A single global lock would serialize all metadata writes. Fix: fine-grained read/write locks on the directory tree (lock the path components you touch, not the whole tree), so independent subtrees mutate concurrently. Reads (the vast majority - open/stat/list) take shared locks and run in parallel. Metadata reads dominate metadata writes, so a reader-friendly lock scheme keeps throughput high.

(c) Edit-log write amplification. Every namespace mutation must be made durable before it is acked (so a name node crash does not lose the fact that a file was created). Writing each edit synchronously to disk one at a time caps mutation throughput at disk fsync latency. Fix: batch and group-commit the edit log - accumulate many edits and fsync them together, amortizing the disk sync across hundreds of operations. This is the same group-commit trick databases use for their WAL.

When one name node genuinely is not enough: federation and sharding metadata

At exabyte scale, metadata exceeds one machine’s RAM (the 1.5 TB figure from the BoE). Two ways to scale the metadata tier horizontally:

  • Namespace federation (HDFS Federation). Partition the directory tree across multiple independent name nodes by subtree: name node 1 owns /user/*, name node 2 owns /data/*, etc. Data nodes are shared - each stores chunks for any name node and sends block reports to all of them. Each name node is independent (no cross-talk), so this scales metadata linearly but gives up a single global namespace lock (cross-subtree rename becomes a copy).
  • Sharded metadata store (the Colossus approach). Instead of holding all metadata in one process’s RAM, store it in a scalable distributed key-value store (e.g. a Bigtable/Spanner-like system) and run many stateless metadata servers in front of it. The metadata itself is sharded and replicated by the underlying KV store, removing the single-box RAM ceiling entirely. This is how Google moved past GFS’s single-master limit. More moving parts, but no hard metadata cap.

The honest interview framing: start with one name node because it fits (the BoE proves 10 PB of metadata is ~15 GB), make it fast with in-RAM structures, fine-grained locks, and group-committed edit logs, and only federate or shard the metadata when file/chunk count - not bytes - outgrows a single machine’s memory.

2. Name Node High Availability: It Is Also a Single Point of Failure

A single name node is not just a potential bottleneck; if it dies, the cluster is headless. The data nodes still hold every byte, but nobody knows which bytes are where, so no client can open a file. Durability of data is fine (the chunks are safe on data nodes); it is availability that is at risk. You must make the name node’s state durable and make failover fast.

Naive: periodic checkpoint only (the GFS v1 weakness)

Snapshot the in-RAM metadata to disk every so often (the FsImage). On crash, restart the name node and load the latest image. Where it breaks: everything since the last checkpoint is lost (all file creates/renames in that window), and loading a multi-GB image plus rebuilding state from block reports takes many minutes to tens of minutes. During that whole restart the cluster is down for metadata. Unacceptable for 99.99%.

Better: edit log + checkpoint, then a hot standby

The durable-state design has two pieces working together:

FsImage  : a point-in-time snapshot of all metadata (the namespace + file->chunk map).
EditLog  : an append-only journal of every mutation since the last FsImage
           (create, delete, rename, new chunk, length change), group-committed to disk.

Recovery = load latest FsImage, then replay EditLog on top. 
Checkpointing = periodically fold the EditLog into a new FsImage so replay stays short.

This gives durability (no acked mutation is lost - it is in the edit log before the ack) but by itself still has a slow cold restart. To get fast failover, run a standby name node:

  • The active name node writes every edit to a shared, replicated edit log - not a local disk, but a quorum journal (an ensemble of JournalNodes using a majority-write, like a small Paxos/Raft log) so the log survives the active’s death.
  • The standby name node continuously tails that shared edit log and applies every edit to its own in-RAM copy of the metadata. It is always a few edits behind the active - a hot copy, not a cold image on disk.
  • Block reports go to both active and standby, so the standby also knows the chunk-to-node map and does not have to rebuild it from scratch on promotion.
   ACTIVE NN  --edits-->  [ JournalNodes: J1 J2 J3 ]  <--tail--  STANDBY NN
      ▲  writes majority (2 of 3) before ack             replays edits,
      │                                                   warm metadata in RAM
   clients                 data nodes send block
                           reports to BOTH NNs

Failover mechanics and the split-brain guard. A separate coordination service (ZooKeeper, via a ZKFailoverController) health-checks the active. On failure it promotes the standby. Because the standby already has warm metadata and the chunk map, promotion is seconds, not minutes. The dangerous case is two active name nodes (split-brain): the old active is alive but partitioned, the standby gets promoted, and now two brains hand out conflicting leases and allocations. Guards:

  • Fencing. Before the standby becomes active, the old active must be fenced - the JournalNodes refuse edits from a name node that is not the current epoch holder (each active gets a monotonically increasing epoch number; a stale active’s writes are rejected by the quorum). Optionally STONITH (“shoot the other node in the head”) kills the old process.
  • Quorum journal. Because edits require a majority of JournalNodes to ack, a partitioned old active that cannot reach a majority simply cannot commit any new edit - it is harmlessly stuck, not silently diverging.

So the layered answer to “the name node is a single point of failure”: durable state via group-committed edit log to a quorum journal, a hot standby that tails the log and receives block reports for warm metadata, ZooKeeper-driven failover in seconds, and epoch-fencing to prevent split-brain.

3. Chunk Placement and the Write Pipeline

Where you put the R replicas of a chunk decides your durability (can one failure or one rack outage lose all copies?) and your write/read throughput (can you use the network efficiently?). And how you write them decides whether the client’s uplink becomes the bottleneck.

Naive placement: R random nodes

Pick 3 random data nodes for each chunk’s replicas. Where it breaks: randomly, some replica sets land all three copies in the same rack. One top-of-rack switch failure or one rack power loss then takes out all three replicas at once - correlated failure, data lost. Random placement ignores the failure domains that actually fail together.

Better: rack-aware placement

Treat racks as failure domains and spread replicas across them. The classic (HDFS) R=3 policy:

Replica 1: on the node where the writer is (or a random node if writer is off-cluster)
           -> cheap local write, good write locality.
Replica 2: on a node in a DIFFERENT rack
           -> survives a whole-rack failure.
Replica 3: on a different node in the SAME rack as replica 2
           -> cheaper than a third cross-rack hop, still rack-redundant.

Why this specific layout: two racks means a single rack failure never loses all copies (at least one replica is in the other rack), while putting replicas 2 and 3 in the same second rack avoids spending three separate cross-rack network trips on every write (cross-rack bandwidth is the scarce resource). It balances durability (survive a rack), write bandwidth (only one cross-rack hop), and read locality. The name node also factors in free space and current load so writes do not all pile onto the emptiest-but-busiest nodes, and avoids nodes that are decommissioning or recently flaky.

Naive write: the client sends all R copies itself, uploading the same bytes 3 times. That triples the client’s outbound bandwidth and makes its NIC the bottleneck. The fix is pipelined replication:

Client --bytes--> DataNode A --forward--> DataNode B --forward--> DataNode C
   (client uploads ONCE; each node forwards downstream while receiving)

Data is pushed through the chain as a stream of packets; nodes forward a
packet onward as soon as they receive it (pipelined, not store-and-forward),
so latency is ~ one link, not the sum.

Then control/commit:
  Primary (lease holder) assigns a serial order to the mutation,
  applies it, tells B and C to apply in that order; they ack up the
  chain; primary acks client.

The client’s uplink carries each byte once; the data nodes’ inter-node links do the fan-out. The lease mechanism makes one replica the primary for a chunk for a bounded time; all mutations to that chunk serialize through the primary, which assigns a global order so all replicas apply writes identically. The lease is renewed via heartbeats and expires if the primary dies, so the name node can safely grant a new lease without two primaries existing. This is how concurrent appenders to the same file get a single, consistent mutation order without the name node being in the data path.

Consistency note (the relaxed model). After a successful pipelined write acked by all replicas, the region is defined - all replicas are byte-identical. A failed write may leave replicas inconsistent for that region; the client retries, and because appends are retried, a record may appear duplicated or there may be padding between records. Clients cope with application-level checksums and record IDs to skip duplicates and detect gaps. We accept this weaker “at-least-once append” semantics because it buys huge write throughput; strict exactly-once in-place consistency would require locking that kills throughput.

4. Failure Detection and Fast, Non-Disruptive Re-Replication (the core hard part)

At 500 nodes, node and disk failures are a daily event, not an exception. The system’s durability depends entirely on noticing a failure fast and rebuilding the lost replicas back to R before another failure hits the same chunk - while not letting that rebuild traffic strangle live client I/O.

Detection: heartbeats and block reports

  • Heartbeats every ~3 seconds from each data node to the name node carry liveness, free space, and load. If the name node misses heartbeats from a node for a threshold (say ~30-60 s, tuned to avoid false positives during GC pauses or brief network blips), it marks the node dead and treats every replica that node held as lost.
  • Block reports (periodic, e.g. hourly, plus incremental on change) are the full list of chunks a node actually has on disk. They catch what heartbeats cannot: silent data loss (a disk died but the node is up), bit-rot caught by per-chunk checksum scrubbing, and stale/extra replicas. The name node reconciles reports against its map - a chunk missing from reports is under-replicated; a chunk with too many copies gets an excess replica deleted.

Naive re-replication: rebuild everything, immediately, FIFO

When a node dies, enqueue all ~750K of its chunks (from the BoE) and copy them back to R=3 as fast as possible, in arbitrary order, at full network speed. Two things break:

  1. It starves live writes. 96 TB of rebuild traffic at full speed saturates data node NICs and disks, and client reads/writes stall behind the recovery copies. The cluster “heals” by becoming unusable. (The BoE showed a full-node rebuild is multiple TB - run it flat-out and clients feel it.)
  2. It ignores urgency. A chunk that just dropped from 2 copies to 1 copy is one failure away from total loss and must be fixed first; a chunk that dropped from 3 to 2 still has redundancy and can wait. FIFO treats them equally, leaving the most-fragile chunks exposed longer than necessary.

Better: prioritized, rate-limited, spread-out background recovery

The replication manager on the name node turns recovery into a prioritized, throttled scheduler:

(a) Prioritize by how under-replicated a chunk is. Maintain priority queues keyed on current replica count:

Priority 0 (CRITICAL): chunks with 1 remaining replica  -> one failure from data loss. Fix first.
Priority 1:            chunks with 2 of 3 replicas       -> restore when criticals are handled.
Priority 2+:           lower-urgency / over-min cases.
Also boosted: chunks of files currently being read/written (keep hot data safe).

The name node always drains the most-critical queue first, so the mean time a chunk spends at replica-count 1 (the only state where one more failure loses it) is minimized. This is the single most important durability lever - durability is governed by the time-to-repair of the most-under-replicated chunks, not by average rebuild throughput.

(b) Spread the rebuild across many sources and targets. The lost node’s ~750K chunks each have surviving replicas scattered across hundreds of other nodes. Recovery copies therefore originate from many different source nodes in parallel and land on many different target nodes, so no single node is the rebuild bottleneck. A thousand small parallel copies heal far faster than one node serially re-uploading everything. This parallelism is exactly why real clusters restore criticals in minutes despite the multi-hour flat-out figure.

(c) Rate-limit so rebuild never starves clients. Cap the bandwidth and concurrency each data node may spend on replication traffic (e.g. a per-node ceiling like a few hundred Mbps, or a fraction of NIC capacity), and cap the number of concurrent recovery streams the name node schedules. Live client I/O gets priority; recovery uses the slack. There is a deliberate tension here:

Recovery speedDurability (repair window)Client impact
Aggressive (high bandwidth cap)Chunks healed fast, small danger windowClient reads/writes stall
Throttled (low bandwidth cap)Longer under-replicated window, higher loss riskClients unaffected

The resolution is adaptive and priority-aware: critical (replica-count-1) chunks are allowed to rebuild aggressively because the durability risk dominates, while the long tail of merely-2-of-3 chunks rebuilds gently in the background using spare bandwidth. You spend your bandwidth budget where the data-loss risk actually is.

(d) Avoid replication storms and transient over-reaction. A brief network partition can make many nodes look dead at once, triggering a massive, pointless re-replication of chunks whose replicas are actually fine and about to reappear. Guards: a grace period before declaring a node dead; treat a node that comes back with its chunks intact as recovered (cancel its pending rebuilds and delete the now-excess new copies); and cap the total cluster-wide recovery traffic so even a real multi-node loss cannot overwhelm the network. Decommissioning a node gracefully is the planned version of this: mark it draining, re-replicate its chunks elsewhere at a steady throttled rate, then remove it - no urgency, no client impact.

Rebalancing rides on the same machinery: when a new empty node joins, or nodes drift to uneven utilization, the name node schedules low-priority background copies to level out space, using the same rate limits so it never disturbs live traffic.

The complete answer: detect fast via heartbeats, catch silent loss via block reports and checksum scrubbing, and heal via a priority queue that fixes the most-fragile chunks first, spread across many source/target pairs for parallelism, rate-limited and priority-aware so critical rebuilds go fast while the long tail stays polite - keeping the under-replicated window tiny without ever stalling client writes.

API Design & Data Schema

Client-facing file API

The client library speaks a file-oriented API; under the hood it is split into metadata RPCs (to the name node) and data streaming (to data nodes).

# Namespace / metadata (name node)
POST   /fs/v1/files                 # create a file (empty), returns file handle
       { "path": "/logs/app.log", "replication": 3, "chunk_size": 134217728 }
       -> { "file_id": "f_8821", "status": "created" }

GET    /fs/v1/files?path=/logs/app.log        # stat: size, chunk list, perms
       -> { "file_id":"f_8821","length":5368709120,
            "chunks":["c_1001","c_1002", ...], "replication":3 }

GET    /fs/v1/locate?chunk=c_1002             # where are this chunk's replicas?
       -> { "chunk_id":"c_1002","version":7,
            "locations":[ {"node":"dn-14","addr":"10.0.3.14:50010","rack":"r2"},
                          {"node":"dn-88","addr":"10.0.7.88:50010","rack":"r5"},
                          {"node":"dn-90","addr":"10.0.7.90:50010","rack":"r5"} ],
            "primary":"dn-14" }

POST   /fs/v1/files/{file_id}/append          # allocate a new chunk to append to
       -> { "chunk_id":"c_1003","version":1,"primary":"dn-22",
            "pipeline":["dn-22","dn-45","dn-46"], "lease_ttl_s":60 }

DELETE /fs/v1/files?path=/logs/app.log        # delete (lazy GC of chunks)
POST   /fs/v1/rename { "from":"/a", "to":"/b" }
GET    /fs/v1/list?path=/logs                 # directory listing
# Data plane (direct to data nodes, NOT the name node)
READ   chunk c_1002 [offset,len]  from any replica (client picks nearest)
WRITE  pipeline: client -> dn-22 -> dn-45 -> dn-46 (push), then COMMIT to primary dn-22
# Data node <-> name node (control plane, internal)
HEARTBEAT { node, free_bytes, load, timestamp }        every ~3s
BLOCK_REPORT { node, [ {chunk_id, version, length, checksum} ] }  periodic + incremental
REPLICATE_CMD { chunk_id, from_node, to_node }         name node -> source node
DELETE_CMD   { chunk_id }                              remove excess/orphan replica

Notes: locate returns replicas sorted by proximity to the caller so reads prefer the nearest/least-loaded copy, and includes a chunk version so a stale replica (one that missed updates while its node was down) is detected and ignored until it catches up or is re-replicated. append hands back the whole pipeline and a time-bounded lease.

Data model: in-RAM metadata + chunk files on disk

Access is: resolve a path to an ordered chunk list, then resolve each chunk to its replica locations - all keyed lookups at high rate, held in RAM for microsecond latency, made durable by an append-only edit log. That is a custom in-memory index backed by a write-ahead log, not a relational database. SQL is the wrong tool for the hot metadata: a disk-backed relational engine cannot serve 50K keyed metadata lookups/sec at microsecond latency the way an in-RAM tree + hash map can, and we do not need joins or ad-hoc queries over metadata. (The durable record of metadata is the FsImage + edit log, and at exabyte scale the metadata can be offloaded to a distributed KV store as in the Colossus approach - still key-value, not relational.) The chunk data itself is just ordinary files on each data node’s local file system, named by chunk ID, with a sidecar checksum file.

Name node in-RAM structures:

Inode / file record:
  file_id        STRING  (PK)
  path           STRING  (resolved via the namespace tree)
  length         INT64
  replication    INT8    (target R, default 3)
  chunk_list     [chunk_id]   ordered list of the file's chunks
  owner/perms    small
  mtime          INT64

Namespace tree:  directory -> children  (in-RAM tree, fine-grained R/W locks)

Chunk record (the chunk->nodes map - the big one, ~78M entries):
  chunk_id       STRING  (PK)
  version        INT32   (bumped on each mutation; stale replicas detected)
  length         INT32
  locations      [node_id]     current replica holders (rebuilt from block reports)
  primary        node_id|null  current lease holder (for in-flight writes)
  lease_expiry   INT64|null

Data node record:
  node_id        STRING (PK)
  addr           STRING (host:port)
  rack_id        STRING (failure domain for placement)
  free_bytes     INT64
  last_heartbeat INT64
  state          ENUM   (active | draining | dead | decommissioned)

The locations field is not persisted in the edit log - it is reconstructed from data node block reports on startup, because the data nodes are the ground truth for what is actually on disk. Only the namespace and the file->chunk mapping (and versions) are journaled. This is a deliberate split: persist the facts only the name node knows (the namespace), rebuild the facts the data nodes know (replica locations) from them directly.

On a data node (on local disk):

/data/chunks/c_1002            # the raw 128 MB (or less) chunk bytes
/data/chunks/c_1002.meta       # per-chunk checksums (e.g. CRC per 512KB) + version

The per-chunk checksum enables the data node to detect bit-rot during periodic scrubbing (background re-read + verify) and lets readers reject corrupt data and fail over to another replica, which then triggers re-replication of the good copy.

Bottlenecks & Scaling

Where it breaks first, in order, and the fix for each:

1. Name node metadata outgrowing RAM (breaks first as file count grows). Metadata scales with number of files/chunks, not bytes. Billions of tiny files blow past one machine’s RAM (the small-files problem). Fix: large chunks (128 MB) to keep chunk count low; pack small files into containers at the app layer; federate the namespace across multiple name nodes by subtree, or move metadata into a sharded distributed KV store (Colossus-style) when it truly exceeds one box.

2. Name node as a single point of failure. If the only name node dies, the cluster is headless (data is safe but unreachable). Fix: durable edit log to a quorum journal + periodic FsImage, a hot standby that tails the log and receives block reports (warm metadata), ZooKeeper-driven failover in seconds, and epoch-fencing against split-brain.

3. Re-replication starving live client I/O. A dead node triggers multi-TB of rebuild traffic; run flat-out and it saturates NICs/disks and stalls clients. Fix: rate-limit per-node recovery bandwidth and cap concurrent recovery streams, prioritize critical (replica-count-1) chunks to rebuild aggressively while the 2-of-3 tail rebuilds gently on spare bandwidth, and spread copies across many source/target pairs for parallelism.

4. Slow repair widening the data-loss window. Durability is set by how long a chunk sits under-replicated; a second failure during that window can zero a chunk. Fix: priority queues by replica count so the most-fragile chunks heal first, fast detection via heartbeats, and block reports + checksum scrubbing to catch silent loss early so repair starts sooner.

5. Correlated failure losing all replicas at once. Random placement can land all 3 copies in one rack; a rack/switch failure then loses the chunk. Fix: rack-aware placement (replicas across at least two racks/failure domains); for cross-datacenter durability, place one replica in another DC or use erasure coding across DCs.

6. Client uplink bottleneck on writes. Naively uploading R copies triples the writer’s outbound bandwidth. Fix: pipelined replication - client uploads once, data nodes forward downstream; the lease/primary serializes concurrent mutations so all replicas converge without the name node in the data path.

7. Hot file / hot chunk read skew. A popular file (a widely-read reference dataset) concentrates reads on its R replica holders. Fix: increase the replication factor for hot files (more replicas = more read bandwidth), spread reads across replicas by proximity/load in the locate response, and let clients cache chunk locations. For read-mostly archival data, erasure coding cuts storage cost while keeping durability.

8. Storage cost of 3x replication. R=3 means 200% overhead; at exabyte scale that is enormous. Fix: erasure coding (e.g. Reed-Solomon 6+3: 1.5x overhead instead of 3x, same fault tolerance) for cold/archival data, keeping full 3x replication only for hot, write-heavy data where reconstruction cost on read would hurt. This is the standard HDFS-EC / GFS-successor trade.

9. Replication storm on transient partitions. A network blip makes many nodes look dead, triggering needless mass re-replication. Fix: a grace period before declaring death, cancel-and-reclaim when a node returns with intact chunks, and a global cap on cluster-wide recovery traffic so even a real multi-node loss cannot overrun the network.

Wrap-Up

The trade-offs that define this design:

  • Separate control plane from data plane. The name node handles only metadata (tiny, frequent, in-RAM); file bytes stream directly between clients and data nodes. This single decision is what lets one name node coordinate a petabyte cluster - route data through it and the whole thing collapses on bandwidth.
  • One (logical) name node over a fully distributed metadata scheme, until it does not fit. We accept a central brain because the BoE proves 10 PB of metadata is ~15 GB of RAM, and a central index gives simple, strongly-consistent namespace operations. We pay for it with HA machinery (edit log + quorum journal + hot standby + fencing) and only federate/shard metadata when file count, not data size, outgrows one machine.
  • Replication + fast prioritized repair over fancier encodings for hot data. R=3 with rack-aware placement and priority-queue re-replication buys extreme durability and simple fast reads/writes, at 3x storage cost. We switch to erasure coding (1.5x) only for cold data where the read-time reconstruction cost is acceptable - spending storage where access is hot, spending CPU where data is cold.
  • Relaxed data consistency over POSIX semantics. Append-mostly, at-least-once writes with client-side checksums and dedup, rather than linearizable in-place overwrites. We give up strict consistency to get massive write throughput, which is correct for the bulk analytics workloads this system actually serves.
  • Repair aggressiveness tuned by risk, not a fixed rate. Critical replica-count-1 chunks rebuild fast because data-loss risk dominates; the long tail rebuilds on spare bandwidth so live writes never stall. Durability is governed by the repair time of the most-under-replicated chunks, so that is exactly where the bandwidth goes.

One-line summary: files split into fixed-size chunks, each replicated R=3 across rack-aware commodity data nodes, indexed by a single in-RAM name node that is kept fast (metadata-only, fine-grained locks, group-committed edit log), kept available (quorum journal + hot standby + fencing), and kept durable by heartbeat-driven failure detection plus prioritized, rate-limited, parallel background re-replication that heals the most-fragile chunks first without ever starving client writes - trading storage overhead and strict consistency for petabyte-scale throughput that survives daily hardware death.