Deep Dive: Where Upload Chunks Land, and How Progress Is Tracked
Companion to the main guide's Upload. That part covers the protocol — resumable, chunked, Content-Range, 308 Resume Incomplete. This file answers the follow-up questions: physically, where do the 256 KB chunks go while upload is in progress, and how does the server know which bytes it already has?
The Core Misconception to Clear Up First
The natural mental model is "the server keeps a checklist of which chunks have arrived and which haven't" — like a torrent client with a bitmap of pieces. That's not how this protocol works, and it's actually simpler than that.
Chunks must arrive in strict order, starting from byte 0, each one picking up exactly where the last acknowledged one left off. There's no such thing as "chunk 7 arrived but chunk 4 is missing" — chunk 7 can't be accepted until byte-offset for chunk 6 has already been acknowledged, because each PUT declares its Content-Range relative to a single, growing, contiguous stream.
So the server doesn't track a set of received pieces — it tracks a single number: "how many contiguous bytes, starting from 0, have I durably received so far." That's it. One integer (a byte offset), not a ledger of chunks.
Where That One Number Lives
That offset is exactly what comes back in the Range header of a 308 Resume Incomplete response:
For the server to answer that question instantly, on any request, from any frontend — this needs to be small, fast-to-read state, kept separate from the actual video bytes. This mirrors the same split the main guide describes for durable storage in general (see Origin storage): Colossus itself keeps file metadata in Bigtable, separate from the actual data blocks, specifically so metadata lookups don't require touching the (much larger, much slower) data path. The upload session's "how many bytes so far" counter is the same idea at a smaller scale — a lightweight metadata record (keyed by the session URI) tracked independently of wherever the growing video blob physically lives.
This isn't publicly documented at the YouTube-specific level, but it's the same resumable-upload convention Google uses uniformly across YouTube, Drive, and Cloud Storage (the main guide's Upload part already notes this) — and the protocol's own observable behavior (a single contiguous offset, not a chunk map) is confirmed simply by reading what 308 Resume Incomplete returns.
Where the Bytes Themselves Go
Two things are true simultaneously, and the distinction matters:
- The server only acknowledges bytes once they're durable. A
308response reportingRange: bytes=0-2097151is a durability claim, not just "I received it into memory." If the server crashed the instant after sending that response, those first 2 MB would still be safely there. This is why resuming from the acknowledged offset after a dropped connection is safe — the client isn't gambling on bytes that only existed in a frontend's RAM. - The object is built incrementally, not assembled at the end. Rather than buffering the whole upload somewhere temporary and only writing the "real" file once the last chunk arrives, each acknowledged chunk is appended to a single growing object as it arrives — an append-style write, not a collect-then-assemble one. This is a natural fit for GFS-style file systems (which Colossus descends from) — append is a first-class, well-optimized operation in that design, specifically because many Google systems (logs, and uploads like this one) write data incrementally rather than all at once.
Put together: there's no separate "staging area" that later gets copied into place. The partially-uploaded video is, at every point during the upload, a prefix of the same durable object it will be when upload finishes — it just isn't complete yet. Finishing the upload (the final chunk, matching the declared TOTAL) doesn't trigger a "move" or "commit" step so much as it means the append stream has reached its declared end, at which point the Upload part’s 201 Created fires and the object is considered a finished, durable source file — which is the event that kicks off the fan-out described in the Processing part.
Does Bigtable Track the Chunk Sequence?
No — and it's worth being precise about which layer owns that job, because it's easy to conflate two separate pieces of metadata.
Colossus tracks chunk order itself, internally. Colossus's own metadata service keeps, per file, an ordered list: filename → [chunk_1, chunk_2, chunk_3, ...]. That list is the sequence — chunk 3 is chunk 3 because of its position, not because of a stored sequence number. And "total chunk count" isn't a field anywhere either; it's just the list's current length, which grows by one every time an append lands. Bigtable never sees or duplicates this — Bigtable's own SSTables and logs are themselves just ordinary Colossus files, so Bigtable is a client of this chunk-list mechanism, not a second copy of it.
Bigtable's role, if it appears here, is one layer up. The classic pattern (documented in the original Bigtable paper) is: don't store large blobs inline in an LSM-tree — store a pointer to a Colossus file instead. Applied here, that would mean a Bigtable row keyed by something like video_id, with a column holding the Colossus filename for the durable source file — one link to a whole file, not a link per chunk.
Don't conflate this with resume/progress tracking
It's tempting to assume that on every dropped connection, the server re-derives "what's the next chunk" by querying Colossus's chunk list. It doesn't — that would mean walking filesystem-internal metadata on every status check, which is exactly the slow-path problem the "small fast metadata, separate from large slow data" pattern exists to avoid.
These are three distinct records, at three different layers, read at three different times:
| Record | Holds | Read when |
|---|---|---|
| Progress/session record | one integer — durable-bytes-so-far | on every 308 resume/status-check |
File-identity pointer (video_id → Colossus filename) | which Colossus file this upload is | once, when the session starts / at finalize for fan-out |
| Colossus's own chunk-handle list | [chunk_1, chunk_2, ...] for that file | never, by the upload-serving logic — purely internal to Colossus |
The progress counter is kept correct by being updated in lockstep at write time — the same acknowledged step that appends a chunk to the Colossus object also bumps the counter — not by being recomputed from Colossus on read. So a resume after a dropped connection is one fast KV read of the counter, never a query into Colossus's chunk bookkeeping.
Why 256 KB Specifically
The main guide's Upload part already notes chunks must be a multiple of 256 KB (except the final one). Worth being precise about what this constraint is not: it does not mean Colossus's underlying storage blocks are 256 KB — GFS-descended systems like Colossus historically use much larger internal chunk sizes (tens of MB), because very small chunks would create excessive metadata overhead at Google's scale (exactly the problem Bigtable-backed metadata was built to avoid).
256 KB is better understood as a client-protocol buffering convention — small enough that a mobile client on a weak connection isn't gambling a huge amount of re-transfer if a chunk fails mid-flight, but large enough (and power-of-two aligned) to be efficient for the network stack and any intermediate buffering layer to handle without excessive per-request overhead. It's a client↔frontend granularity decision, sitting several layers above wherever the data eventually lands inside Colossus's own, much coarser internal chunking.
How 256 KB Pieces Become 64 MB Chunks — the Rollover Mechanism
There's no explicit "conversion" step between the two sizes. The frontend never tracks 64 MB boundaries at all — it just keeps appending each 256 KB piece to the same open Colossus file. The two granularities are decoupled by a rollover mechanism inside Colossus itself, driven purely by accumulated byte offset:
- Colossus's client library tracks the current chunk's remaining space, not the frontend. For any append, it converts the file's running write offset into a chunk index via plain integer division (
offset ÷ 64 MB). - When an append would overflow the current chunk, Colossus rolls over — mid-stream, transparently. This is documented GFS "record append" behavior: if the next append would push the chunk past 64 MB, Colossus pads the current chunk out to exactly 64 MB, closes it, requests a brand-new chunk handle from its metadata service, and retries the append there. The frontend just sees the append succeed — it never knows a rollover happened.
- Concretely:
64 MB ÷ 256 KB = 256, so roughly every 256th piece triggers a rollover — a coincidental ratio, not something the upload protocol is aware of or designed around.
Net effect: one continuous 256 KB-chunked append stream in, one 64 MB-chunked file out — with no coordination required between the two layers.
Putting It Together
The session record (a small, fast-to-read "offset so far" note) and the growing video object (large, append-only, living in durable storage) are two different things, updated together but stored separately — the same "small fast metadata, separate from large slow data" pattern that recurs throughout this whole pipeline (Colossus/Bigtable in the Origin storage part, the CDN's popularity-weighted cache metadata in the Global distribution part).