KatInterview

Resumable Large-File Transfer Service with Verified Chunks

System DesignModel answer
MediumModel answerSystem Designsystem-designresumable-uploadobject-storage

Last updated

Design a storage-backed service that moves very large files in resumable pieces, checks integrity end to end, serves byte ranges, and only exposes files once fully committed.

Problem

Your team needs a service for moving files that are far too large to send in a single HTTP request without failing. Users on flaky networks should be able to start a transfer, lose connectivity, and pick it up later, possibly from a different process or device.

Design the service end to end.

Requirements

  • The file contents live in object storage. Metadata (ownership, status, hashes, versions) lives in a separate store.
  • A client can drop off after any chunk and resume later from a different process.
  • Downloads must support byte ranges.
  • A download must never return data from a file that has not been committed.
  • Re-sending a chunk, or re-sending the "finish" request, must be safe (idempotent).
  • Multiple clients can be active at once, and access must be authorized.
  • Abandoned, unfinished transfers must eventually be cleaned up.

What to cover

  1. The API surface for starting, continuing, finishing, and aborting an upload, plus the download API.
  2. How chunks are identified and addressed, and what happens on duplicates or out-of-order arrival.
  3. How integrity is verified for each chunk and for the whole file.
  4. How completion is made atomic, and how in-progress state is kept apart from committed state.
  5. Authorization for uploads and downloads.
  6. The range-download flow, including caching and load protection.
  7. Cleanup, monitoring, abuse controls, and failure recovery.

Questions worth raising with the interviewer

  • What are the maximum file size, the allowed chunk size range, and the acceptable time to finalize an upload?
  • Can chunks arrive in any order? Are committed versions immutable?
  • Which hash algorithm is expected for chunks and for the full object?

Hints

Hint 1

Model an upload as a session with its own ID and a state machine (open, completing, committed, aborted, expired). Chunks are addressed by (session, index), so a retry overwrites or matches the same slot instead of creating a new one.

Hint 2

Keep two worlds apart: staging objects and session rows for in-progress data, and a committed file/version record that downloads read from. Completion should be a single conditional metadata write, so readers either see the whole file or nothing.

Hint 3

For cleanup and scale, think about expiry timestamps with a sweeper, storage lifecycle rules for incomplete multipart uploads, and having clients send bytes directly to object storage using short-lived signed URLs rather than proxying them.