CMD Guide
HomeSystem DesignDistributed File System

What is a Distributed File System

What Is a Distributed File System

A distributed file system (DFS) manages files and directories whose data is spread across many physical machines, while presenting a single, unified namespace to clients — so opening /data/logs/2026-07-02.log feels exactly like opening a local file, even though the bytes might live on a rack of machines the client never talks to directly. This is the storage layer underneath systems like Hadoop, large-scale analytics warehouses, and high-throughput data pipelines.

Key characteristics

diagram
diagram

Where This Shows Up

Common use cases

Representative systems

SystemMetadata roleStorage roleNotable trait
HDFSNameNodeDataNodewrite-once-read-many; built for Hadoop/MapReduce-style batch analytics
Google File System (GFS)MasterChunkserver64 MB chunks; relaxed, at-least-once record-append semantics
Ceph (CephFS)Metadata Server (MDS)Object Storage Daemon (OSD)POSIX-compliant; clients compute placement via CRUSH instead of a lookup table
GlusterFSElastic hashing / distributed hash tableBrick (per-server storage volume)Scale-out, POSIX-like, no single metadata master; replicates whole files across bricks
Amazon EFSAWS-managed control planeAWS-managed storageFully managed, POSIX-compatible, mounted over NFS
Microsoft DFSNamespace serverFile server sharesPresents shares from multiple Windows file servers under one namespace path
diagram
diagram

Worked Example: Placing Replicas (Illustrative)

Say a client writes a 300 MB file to an HDFS cluster with a 128 MB block size and replication factor 3. The file splits into three blocks — blk_0, blk_1, blk_2 — onto a cluster of five DataNodes across two racks: Rack A (DN1, DN2, DN3) and Rack B (DN4, DN5).

HDFS's default rack-aware placement policy for each block is:

  1. Replica 1 goes on the node doing the write (or a random in-cluster node if the writer is outside the cluster).
  2. Replica 2 goes on a node in a different rack, so a whole-rack failure can't take out both copies.
  3. Replica 3 goes on a different node in the same rack as replica 2, keeping cross-rack traffic low while still tolerating a single node failure.

Within a target rack, the specific node is not chosen deterministically — the NameNode picks pseudo-randomly among the eligible candidates, weighted by available disk space, to spread load evenly. One possible, illustrative outcome for blk_0 is shown in the diagram above: replica 1 on DN1 (the writer's node), replica 2 on DN4, replica 3 on DN5. Re-run the same write, or run it against a cluster with a different free-space distribution, and replicas 2 and 3 could just as easily land as DN5-then-DN4, or shift entirely if DN4's disks happen to be fuller than DN5's. The rack constraint is guaranteed; the exact node within the rack is not — treat any specific node assignment you see in a diagram or log as one example, not a rule.

Consistency Semantics

"Consistency" in a DFS answers one narrow question: after a write happens somewhere in the cluster, what is a reader — possibly hitting a different replica, possibly racing the writer — guaranteed to see? Different systems answer this very differently, and the answer has real consequences for which workloads a DFS is safe to use for.

HDFS: single-writer, write-once-read-many

GFS: relaxed, "at-least-once" record append

The pattern to notice: neither system chose full POSIX-style consistency — both traded it away deliberately, in different directions, for the specific write pattern they were built to serve (single-writer batch files for HDFS, many-writer shared logs for GFS). The useful question when picking or designing a DFS isn't "is it consistent?" but "consistent for which access pattern, and what does the application have to do to compensate for the rest?"

CAP trade-offs in DFS terms

Under the CAP lens, both HDFS and GFS choose partition tolerance as non-negotiable: a rack switch or network partition must not lose data. The remaining dimension is the consistency/availability trade-off. HDFS pays with availability of concurrent writers (only one writer per file, metadata operations block if the NameNode is down) to buy strong consistency for finalized blocks. GFS pays with record-level consistency (duplicates, gaps, padded records) to keep availability high for hundreds of concurrent appenders. Dropbox-style sync moves the trade-off again: metadata is strongly consistent (small, transactional), while the block store and cross-device propagation are eventually consistent so sync stays available even when one device is offline.

Pitfalls

The standard mitigation is to stop treating the master as a single process. HDFS's answer is HDFS High Availability (HA): an Active NameNode and a hot-standby Standby NameNode share the filesystem edit log through a quorum of JournalNodes (the Quorum Journal Manager, QJM) — the Active writes every edit to a majority of JournalNodes before considering it committed, and the Standby continuously tails that same log so its in-memory namespace stays current. DataNodes send block reports to both NameNodes, so the Standby can serve traffic immediately after taking over. On failure, a ZooKeeper-based failover controller (ZKFC) detects the Active is gone and promotes the Standby automatically, typically within seconds. Classic GFS took a lighter-weight version of the same idea: the primary master periodically checkpoints its state and streams operation logs to shadow masters, which lag slightly behind and can serve read-only metadata during an outage — though the original GFS design still needed a slower, more manual recovery to restore full read/write service, a gap Google's GFS successor, Colossus, closed by moving metadata into a fully distributed layer instead of a single (even if replicated) master.

diagram
diagram

DFS or object store? The first fork

Before reaching for a NameNode-and-DataNodes DFS, decide whether you need a filesystem at all. The named alternative is an object store (S3, GCS, Azure Blob): a flat key → blob map behind an HTTP API, no POSIX semantics, no in-place edits, no hierarchical rename. The crossover is concrete:

Conclusion

A distributed file system's real design surface isn't "can it store a lot of data" — replication handles that. It's the three things that actually bite developers in practice: how deterministic the metadata service's placement decisions are (often deliberately not, for load-balancing); what a reader is actually guaranteed to see after a concurrent write (weaker than most people assume, and different by design between systems like HDFS and GFS); and what happens to the whole cluster when the one process that knows where everything lives goes down (nothing works, until that process itself is made redundant via a standby and a replicated log).

Sources

🤖 Don't fully get this? Learn it with Claude

Stuck on What is a Distributed File System? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **What is a Distributed File System** (System Design) and want to truly understand it. Explain What is a Distributed File System from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **What is a Distributed File System** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **What is a Distributed File System** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **What is a Distributed File System** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes