Uploading large files reliably
Chunked, resumable, direct-to-storage uploads: how to move gigabytes over unreliable networks without tying up your servers.
On the roadmap:Staff Engineer · step 4: Real-time at scale
Lesson 17 of 18 · 9 min read · quiz · exercise
Why large uploads are hard
A 5 GB file on a normal request has many ways to fail:
- A single long connection dies on a flaky network, losing everything.
- Timeouts in load balancers and proxies cut off long requests.
- Your application servers are tied up carrying bytes, and memory or disk fills.
- A failure at 99% means starting again.
- Users want a progress bar and the ability to pause and resume.
The design in one picture
Figure SDA-RWS-17-1 · Chunked, resumable upload flow · © forcsguy.com
Before: upload through your server
After: upload straight to storage
What changed
- Your servers no longer carry large files
- A failed chunk is retried, not the whole file
- Pre-signed URLs keep storage private
Step by step
- Initiate. The client tells the API the file name, size and type. The API checks permissions and limits, and creates an upload session with a unique id.
- Direct to storage. The API returns pre-signed URLs: short-lived, scoped links that let the client upload straight to object storage. Your servers never carry the file.
- Chunk. The client splits the file into parts (for example 5 to 100 MB; object stores typically accept thousands of parts per object) and uploads them, in parallel.
- Verify. Each part carries a checksum (MD5, CRC32C or SHA-256). The storage service or your server checks it, and a bad part is simply re-sent.
- Resume. The session remembers which parts are done. After a drop the client asks which parts exist and sends only the missing ones. Open protocols such as tus standardise resumable uploads.
- Complete. The client sends the list of parts; storage assembles the object.
- Post-process asynchronously. An event triggers virus scanning, type verification, thumbnails or transcoding, and metadata updates. The user sees "processing" until it finishes.
Checking each part
When a part arrives, the store replies with a checksum tag. The client keeps the list of part numbers and tags, and sends it with the final "complete" request, so the store can verify and assemble exactly the parts you meant, in order. A failed part is re-sent alone; assembly of a very large object can take a few minutes, so treat "complete" as asynchronous from the user's point of view.
Smart extras
- Deduplication: hash the file (or chunks) on the client first. If the content already exists in storage, skip the upload entirely and just add a reference (as in cloud file storage services).
- Parallelism and adaptive chunk size: larger parts on fast networks, smaller on poor ones.
- Compression for compressible data before upload.
- Upload acceleration: send to the nearest edge location, which forwards over the provider's backbone.
- Progress and cancellation: the client tracks bytes per part; cancelling aborts the session.
Safety and cost
- Limit size, type and number of concurrent uploads per user, and expire pre-signed URLs quickly.
- Validate on the server, not only in the client: check file type by content, scan for malware, and store uploads in a quarantine area until cleared.
- Use lifecycle rules to delete incomplete multipart uploads after a few days, since unfinished parts cost money until removed.
- Encrypt in transit and at rest; do not let user-provided names choose storage paths.
- Rate limit session creation to prevent abuse.
Failure handling checklist
| Failure | Handling |
|---|---|
| Connection drops mid-part | Retry that part with backoff |
| Client closes the app | Session persists; resume later by listing stored parts |
| Corrupted part | Checksum mismatch, re-upload that part |
| Duplicate completion request | Idempotent: completing twice returns the same result |
| Abandoned upload | Lifecycle rule cleans up the leftovers |
| Processing fails | Retry from the event queue, mark the file as failed, tell the user |
Real-world reading
Related reading
- Determinism (4 parts) in League of Legends ServerRiotgames engineers · RiotgamesCase Studies
- Implementing health checksAmazon Builders' Library · Amazon Web ServicesBlogs
- The Network is ReliableKyle Kingsbury · aphyr.comBlogs
- Bulkheads: Partition and Tolerate Failure in One PartSkife engineers · SkifeCase Studies
Show 6 moreShow fewer
- Natural Language Processing and Content Analysis (2 parts) at Condé NastCondé Nast engineers · Condé NastCase Studies
- Autoscaling Bigtable Clusters based on CPU Load at SpotifySpotify engineers · SpotifyCase Studies
- Ambry: Distributed Immutable Object Store at LinkedInLinkedIn engineers · LinkedInCase Studies
- Big Data Processing (2 parts) at SpotifySpotify engineers · SpotifyCase Studies
- Container (8 parts) at Riot GamesRiot Games engineers · Riot GamesCase Studies
- Architecture of Chat Service (3 parts) at Riot GamesRiot Games engineers · Riot GamesCase Studies
Check your understanding
Question 1 of 3
0 correct so far
Why is it better for the client to upload straight to object storage using a pre-signed URL than to send the file through your application server?
Go deeper
- Amazon S3 multipart upload documentation, and the tus resumable upload protocol by Amazon Web Services; the tus community: tus is an open protocol for resumable uploads
Practise it: Uploads on the wrong part
Everything below is already set up for this lesson: change the design, run the traffic, and see whether you meet the goal.
- 1The task
- 2Build and test
30% of 1,200 requests per second are file uploads. With no object storage the bytes land on the database and the app servers.
Goal: Under 1% errors and a slowest 5% under 300 ms.
Large files do not belong in a database. What stores them cheaply?
Try it yourself
A user uploads a 4 GB video on a mobile connection that drops every few minutes. Describe the protocol so the upload finishes without starting over, and what you do about the abandoned partial uploads of people who never come back.
Click what a strong design here would need:
More in Real systems
© 2026 forcsguy.com. Original lesson text and diagrams. Books and sites linked above belong to their authors.