Highlights

Contents

Part IV
04

Multipart uploads

We split a large transfer into independently recoverable parts without exposing a partial object as finished. Parallelism helps only within the actual shared bandwidth budget. We will compute part ranges, track completion evidence, retry a failed part, and clean up unfinished sessions.

CHAPTER ATLAS / FOLLOW THE READING PATHCHAPTER ATLAS / FOLLOW THE READING PATH1Local, block, file,object storage2Buckets, objects andmetadata3Presigned URLs and directupload4Multipart uploads5Checksums and integrity6Replication anddistributed file systems7Lifecycle and retention8Case study: the mediaupload path

#Section 13Part boundaries and byte ranges

A connection interruption near the end of a large upload should not require retransmitting every byte. Multipart upload creates one upload session whose numbered parts can be transferred separately and combined through an explicit completion operation. The exact supported sizes and limits come from the chosen service.

For Heron’s illustrative 5,000,000,000-byte object and 100,000,000-byte parts, the division is exact: 50 parts. Using inclusive byte ranges, the first is zero through 99,999,999 and the next is 100,000,000 through 199,999,999. The final range begins at 4,900,000,000 and ends at 4,999,999,999.

P=⌈S/p⌉.P=\left\lceil S/p\right\rceil.

Read this as number of parts PP equals total size SS divided by part size pp, rounded upward. The final part can be smaller when the division is not exact. Keep client ranges and service part numbering distinct so zero-based offsets do not become wrong API part identifiers.

NUMBERED PARTS TILE THE OBJECT WITHOUT GAPS OR OVERLAPNUMBERED PARTS TILE THE OBJECT WITHOUT GAPS OR OVERLAP50 × 100,000,000 B = 5,000,000,000 Bpart 1part 50first: 0 to 99,999,999last: 4,900,000,000 to 4,999,999,999inclusive endpoints; each part carries exactly 100,000,000 bytes
Figure 13.14Illustrative decimal-byte partition. Range endpoints are inclusive and do not encode a service’s part-number convention.

#Section 14Initiation and the completion manifest

The storage service returns an upload-session identifier after initiation. The client uploads numbered parts under that identifier and retains the service’s part evidence. Completion submits the ordered manifest the service requires so it can assemble the intended final object.

For the illustrative object, the manifest has 50 entries. A lost local response for one part does not prove the part is absent. Query or retry through the session’s documented part semantics. Do not complete with an accidental subset or stale evidence merely because the application saw some success replies.

A COMPLETION MANIFEST NAMES THE ORDERED PARTS OF ONE UPLOADA COMPLETION MANIFEST NAMES THE ORDERED PARTS OF ONE UPLOADpart Achecksumpart Bchecksumpart Cchecksummanifestupload IDA + checkB + checkC + checkordered assembly → verified object → application publicationillustrative three-part cutaway of the upload mechanism
Figure 13.15Multipart lifecycle. Complete-part evidence is a storage protocol detail; application publication is a later step.

S3’s multipart overview documents initiation, part upload, and completion as distinct operations. Track session ownership in the application. A caller who knows someone else’s upload identifier must not gain completion or overwrite permission through the app’s recovery endpoint.

#Section 15Retry and parallelism costs

One illustrative part fails. Retrying 100,000,000 bytes instead of the complete 5,000,000,000 is a factor of 50 less retransmitted payload in this case. This improvement is about the failed portion, not a guarantee that every upload becomes fifty times faster.

ONE 100 MB PART FAILS: RESEND 100,000,000 B, NOT 5,000,000,000 B (50× LESS)ONE 100 MB PART FAILS: RESEND 100,000,000 B, NOT 5,000,000,000 B (50× LESS)part 1850 parts of 100,000,000 B; only part 18 goes againrepeated failures, setup and completion work are excluded
Figure 13.16Illustrative single-part failure. Protocol setup, repeated failures, and completion work are excluded.

Assume five parts upload concurrently through a shared 10,000,000-byte-per-second link, evenly receiving 2,000,000 each. A part takes 50 seconds. The five-part group transfers 500,000,000 bytes in the same 50 seconds. Ten such groups still require 500 seconds total under the ideal shared-bandwidth model.

FIVE PARTS SHARE ONE 10 MB/S LINK: 2 MB/S EACH, 50 S PER GROUP, 500 S FOR ALL 50FIVE PARTS SHARE ONE 10 MB/S LINK: 2 MB/S EACH, 50 S PER GROUP, 500 S FOR ALL 50object10,000,000 B/s ÷ 5 = 2,000,000 B/s per partparallelism hides per-request waits; it cannot widen the link
Figure 13.17Ideal bandwidth-sharing exercise. Parallelism can hide per-request waits but cannot multiply a fixed link’s payload capacity.

Bound concurrency so parts do not exhaust browser memory, sockets, gateway state, or storage request quotas. Stream each part rather than duplicating the full object in memory. Preserve enough evidence to resume without retaining all payload bytes in the application service.

#Section 16Incomplete sessions and cleanup

A browser abandons the session after uploading two parts. Those parts may remain stored even though there is no completed public object. Under the illustrative size, two parts hold 200,000,000 bytes; ten such unfinished sessions hold 2,000,000,000 bytes.

A cleanup policy aborts stale unfinished sessions after the supported resume horizon. The application and storage lifecycle policy should agree about that horizon. Aborting while a valid client is still uploading can destroy recoverable progress; never completing or aborting wastes retained storage and session state.

TEN ABANDONED UPLOADS WITH 2 PARTS EACH STILL HOLD 2,000,000,000 BTEN ABANDONED UPLOADS WITH 2 PARTS EACH STILL HOLD 2,000,000,000 Beach session: 2 × 100,000,000 B. A lifecycle rule aborts them after the resume horizon
Figure 13.18Illustrative abandonment. Billing and lifecycle timing depend on the storage product.

Reconciliation compares pending application reservations with storage sessions and completed objects. Some objects may have completed while the app failed to publish; some reservations may never have transferred bytes. Give each state a distinct cleanup rule so a background sweep does not delete an actively published object based on an old pending record.