Upload: From an Unreliable Client to a Durable File

Why / The Problem

An upload is a large binary transfer (minutes to hours of video, potentially gigabytes) from an unreliable client — a phone on cellular data, a laptop on hotel wifi — over a connection that will drop mid-transfer at scale. If upload were atomic ("send the whole file or start over"), a dropped connection at 95% of a 4-hour upload would mean re-sending the entire file, which at realistic mobile upload speeds might never complete before the next drop.

How It Works

The client first opens a session with metadata (title, description, privacy) via a POST; the server hands back a session URI in a Location header — this URI, not the video, is the durable handle for the rest of the transfer. The client then streams bytes to that URI in PUT requests, each tagged with a Content-Range: bytes START-END/TOTAL header. Chunk sizes must be a multiple of 256 KB (except the final chunk) — a deliberate alignment constraint that keeps chunk boundaries friendly to the server's underlying block storage.

Resumable upload protocol — surviving a mid-transfer drop
Resumable upload protocol — surviving a mid-transfer drop

If the connection drops mid-chunk, the client re-queries the session with an empty PUT carrying Content-Range: bytes */TOTAL; the server replies 308 Resume Incomplete with a Range header reporting exactly how many bytes it durably has, and the client resumes from there. Nothing already-received is ever retransmitted. This is the same resumable-upload convention Google uses for Drive and Cloud Storage, not something YouTube-specific.

Durable vs. Watchable — Two Separate Promises

Once the file is durable, it does not wait for processing. The Processing part’s work — the full rendition ladder — takes real wall-clock time, sometimes hours for the highest tiers. If publishing were gated on all of that finishing, a video would sit dark exactly when a creator (and often, virality) needs it live.

Two milestones, hit at different times
Two milestones, hit at different times

Durable

The raw bytes you uploaded are safely saved, in full, somewhere that won't lose them. Happens the instant the last chunk is acknowledged (t=0) — nothing about quality or playback is true yet, just "this file cannot be lost anymore."

Watchable

A viewer can actually press play and get a working stream. Needs at least one finished rendition — the system produces the cheapest, universally-compatible one first, so this milestone lands minutes later, not hours later.

Why bother separating them instead of just calling the video "done" once, at the end? Because the two milestones have completely different urgency. A creator (and any early viewers) care about "can I watch this now" — they don't care yet whether it's on the best possible codec. Making everyone wait hours for the full ladder just to protect a quality tier most early viewers won't even benefit from would be optimizing for the wrong thing. This is the same "ship the cheap thing now, earn the expensive thing later" idea from the staged pipeline part — here applied to time (publish now, finish quality later) rather than to cost (the Processing part’s view-count-gated codecs), but it's the identical trade-off.

The Invariants

  • Guarantees: Once a resumable-upload session reaches 201 Created, the source bytes are durable — no re-upload is ever required due to a downstream processing failure; processing operates on a durably stored source and can retry independently of the client.
  • Does not guarantee: That all renditions exist at the moment a video is marked "public." Availability of the video and completeness of the rendition ladder are explicitly decoupled — a deliberate trade of consistency (all formats ready) for availability (some format ready fast).