KatInterview

Crash-Safe Parallel Downloader for Versioned Data Bundles

System DesignModel answer
MediumModel answerSystem Designsystem-designresumable-downloadshttp-range

Last updated

Design a per-node client that pulls huge versioned file bundles over ranged HTTP, resumes after failures using verified chunks, and exposes only fully validated bundles.

A data platform team ships bundles: named, versioned collections of files such as [email protected]. A bundle totals 50 GB to 3 TB and holds anywhere from a handful to several thousand files, each 100 MB to 20 GB. Hundreds of compute nodes must copy a bundle to local NVMe before a job can start. Files are served by an HTTP object store or CDN that supports Range requests.

Design the node-side downloader, a daemon or library that:

  1. Exposes fetch(bundle_id) -> local_path, which returns (or reports progress until it can return) a directory that jobs can read.
  2. Downloads files concurrently and splits large files into byte ranges fetched in parallel.
  3. After a process crash, reboot, or dropped connection, reuses every chunk that was already verified instead of starting over.
  4. Never lets a job see a partially written file or a blend of two different bundle versions.
  5. Downloads a bundle only once per node, even if several jobs request it simultaneously.

Non-functional constraints

  • Try to saturate a 25 Gbps link while keeping roughly 1 GB of buffer memory, a sane number of file descriptors, and the origin's rate limits in mind.
  • Every byte must be checked against a checksum supplied by the publisher.
  • Local disk overhead is bounded: do not hold two full copies of a bundle.
  • Bundles are immutable once published, but the store may later hold a different object at the same URL after a republish. Bytes from two object versions must never be combined.

What to cover

  • Part 1 - Planning and transfer: the manifest format, how it becomes a chunk plan, how concurrency is scheduled and bounded, and what you check on every HTTP response.
  • Part 2 - Resume and publish: what progress state is persisted and where, how a restarted process decides which chunks to trust, and the precise steps that turn a staging area into a visible, complete bundle.
  • Part 3 - Scale and trade-offs: what changes when 500 nodes fetch the same bundle at once, and how you would tune chunk size and parallelism.

Good clarifying questions: Are checksums per file, per chunk, or both? Does the store give a version identifier (ETag or generation) per object? Must the whole bundle appear at once, or may jobs stream individual files?

Hints

Hint 1

Make the manifest the root of identity: address it by its own digest, include per-chunk checksums and the object version, and key all local state by that digest rather than by the bundle name.

Hint 2

Think about ordering for durability: data must be on disk before the progress record that claims it. Then ask what single filesystem operation can make a whole directory appear atomically.

Hint 3

For many nodes, origin egress (hundreds of nodes times terabytes) is the bottleneck, not the node link. Since chunks are content-verified, any cache or peer can serve them safely.