KatInterview

Resumable Parallel Fetcher for Versioned ML Model Files

System DesignModel answer
MediumModel answerSystem Designsystem-designresumable-downloadsbyte-ranges

Last updated

Design a fetcher that pulls a multi-file model in parallel byte ranges, survives failures without redoing verified work, and exposes the model only when complete and consistent.

You are asked to design a component that retrieves a large machine-learning model from a remote store onto local disk, so that a serving process can load it.

A published model version has an immutable manifest. The manifest lists each file in the model, its expected length, and an integrity digest. The remote store may support byte-range requests. Both the network and the fetcher process can fail at any time.

Requirements

  • Fetch the files in parallel, using file-level concurrency and byte-range pieces where the server allows it.
  • After an interruption, continue from verified work rather than starting over, but only if that work still belongs to the same artifact version.
  • Never let the consumer see a partial, corrupted, or mixed-version model.
  • Keep network, disk, and memory use bounded.

No artifact size, concurrency limit, bandwidth target, or distribution topology is given. Explain how those inputs would shape your design.

Part 1: Plan and transfer. Describe the manifest handling, how you split work into pieces, how you control concurrency, and how you validate each transfer. Explain how you prevent ranges from different remote object versions from being stitched together.

Part 2: Resume and publish. Describe how progress is stored durably, what happens on restart, how stale or partially written state is handled, and how a finished download becomes visible to the consumer.

State any clarifying questions you would ask and the assumptions you make.

Hints

Hint 1

Give every download a stable identity (model name, version, manifest digest) and make every request and every progress record carry that identity plus the remote object's version token (for example an ETag or generation number).

Hint 2

Treat a piece as done only after its bytes are written, flushed, and checked against a digest or the expected length; a progress record that is written before the data is durable can lie after a crash.

Hint 3

Download into a staging directory that the consumer never reads, validate the complete set of files there, and then make it visible with a single atomic rename or pointer swap.