Distributed Systems · Google File System

A distributed file system,
built from first principles.

Files are sharded into fixed 1 KB chunks, replicated across storage servers, and indexed by a single metadata authority — so the cluster keeps serving reads and writes even when a node disappears.

1 KB fixed chunks ×3 replication 4 storage servers gRPC transport Survives 1 node loss

01 — Architecture

Three roles, one clean separation

Borrowing the core idea of Google's GFS: keep the metadata layer independent from the storage layer, and let clients talk to each directly.

◆

Naming server

The single metadata authority. It tracks every file → chunk → replica location, hands clients a placement plan on write and locations on read, and orchestrates deletes and self-healing. It never stores or proxies chunk content.

▦

Storage servers

The chunkservers. Each holds only the subset of 1 KB chunks assigned to it, one file per chunk on the local file system. They heartbeat the master and serve chunk bytes straight to clients.

❯

Client library

Hides distribution entirely. It splits files into chunks, asks the master where things go, and reads/writes chunk bytes directly to the storage servers in parallel — the master is never in the data path.

⧉

Sharding

Files are split into fixed-size 1 KB chunks. Each chunk gets a globally unique id and is placed round-robin across the live servers for balance.

⎘

Replication

Every chunk lives on 3 of the 4 storage servers. The spare lets the cluster re-replicate onto a healthy node after a single failure.

♺

Self-healing

A background loop on the master spots under-replicated chunks after a node dies and copies them from a live replica to a spare — restoring the target factor.

02 — Live simulation

Watch the cluster work

Trigger real operations and faults. Tokens travelling the wires are RPCs; the log mirrors what the actual services do.

gfs-cluster · docker compose
heartbeats every 5s
Client operations
Inject faults
metadata RPC data read data write heartbeat failure / delete

03 — Communication protocol

How a client talks to the cluster

Metadata goes through the master; bulk data goes straight to the storage servers. Every call is a gRPC RPC defined in gfs.proto.

    04 — Fault tolerance

    What survives, and what doesn't

    A core design goal: reason explicitly about every failure mode. Try Kill a node then Self-heal in the simulation above to see it live.

    ▦

    A storage server goes down

    Recoverable. Reads keep working from the other replicas; the master routes clients to live copies. Writes continue as long as ≥3 servers are live. The healer re-replicates affected chunks onto the spare to restore the ×3 factor.

    ◆

    The naming server goes down

    Single point of failure for availability. No new metadata operations can run. But chunk data stays safe on disk and metadata is durable in SQLite — once the master restarts and storage servers re-register, the cluster recovers fully.

    ⎘

    The replication math

    With ×3 replication across 4 servers, the cluster survives any single simultaneous storage loss with full automatic recovery. Some reads survive even two losses — as long as every chunk keeps at least one live replica.

    ⚠

    Where data is actually lost

    Unrecoverable only if all three replicas of a chunk fail before healing completes. Interrupted writes leave harmless pending metadata and orphan chunks, both garbage-collected automatically.

    05 — Technology stack

    Built with

    A small, boring, dependable toolchain — fully containerised.

    🐍
    Python 3.12core services
    🔌
    gRPC + Protobufservice contracts
    🗃️
    SQLite · WALdurable metadata
    🐳
    Docker Compose1 master + 4 storage
    📈
    Prometheusmetrics scraping
    📊
    Grafanalive dashboards
    ⚡
    uvdependency mgmt
    🧵
    Thread poolsconcurrent RPCs