Handling Large Files: Uploads, Processing and Delivery
This lesson is for software engineers in system design interviews where users upload or download big files: videos, photos, design files, backups, datasets. Treating a 5 GB file like a JSON request is one of the most common design mistakes, and interviewers know it. By the end you will be able to move bytes directly between clients and object storage, keep metadata consistent with those bytes, process files after upload and deliver them fast, with numbers to back each choice.
Why big files need their own pattern
Run the numbers on a single upload. A user uploads a 2 GB video over a 20 megabit per second home connection. 2 GB is 16,000 megabits, so the upload takes 16,000 / 20 = 800 seconds, about 13 minutes.
If that upload flows through your application servers, each one holds an open connection and buffers data for 13 minutes. A thousand simultaneous uploads tie up a thousand connections doing nothing but copying bytes, and a deploy or a crash in that window kills every upload in progress. Your stateless API servers have become stateful, slow file relays. Meanwhile, a dropped Wi-Fi connection at minute 12 means starting over.
The interviewer wants to see three separations: bytes go to object storage, not through your servers; metadata lives in your database; and processing happens asynchronously after upload.
Uploads: send bytes straight to storage
Presigned URLs
Object stores can issue a presigned URL: a URL that grants permission to upload (or download) one specific object for a limited time, signed with your credentials so the client never sees them. The flow:
The client asks your API: "I want to upload
holiday.mp4, 2 GB, typevideo/mp4."The API checks permissions and quotas, creates a metadata row with status
pending, and returns a presigned URL valid for, say, 15 minutes, for the object keyuploads/user-123/f8a2....The client uploads the bytes directly to object storage using that URL.
Storage notifies your system that the object exists (an event), or the client calls
POST /files/{id}/complete; either way the row moves touploaded.
Your API servers handle two small requests. The storage service, which is built for exactly this, handles 2 GB. You control what can be uploaded through what you sign: the key, the content type and an expiry. Size needs care. A presigned PUT can pin an exact Content-Length, a presigned POST policy can set an allowed size range, and with multipart you sign only as many part URLs as the declared size needs.
Multipart and resumable uploads
A single 2 GB request fails completely if the connection drops. Multipart upload splits the file into parts that upload independently, in parallel, and are assembled at the end. As a concrete example, Amazon S3 requires each part except the last to be at least 5 MiB and allows up to 10,000 parts. A 2 GB file in 100 MB parts is 20 parts. If part 15 fails, the client retries part 15 only, not the whole file.
Resumable upload builds on this: the client records which parts succeeded (or asks the server), so after closing the laptop and reopening it hours later, it uploads only the missing parts. On mobile networks this is the difference between a feature that works and one that does not.
Checksums and deduplication
Corruption happens in transit and in buggy clients. Have the client compute a checksum per part (and a hash of the whole file), send it with the upload, and let storage verify it. Store the whole-file hash, such as SHA-256, in the metadata row.
That hash also enables deduplication: if the same content already exists, point the new metadata row at the existing object instead of storing a second copy. Within one user's files this is safe. Across users, be careful: if the system reveals "this file already exists" (for example by finishing an upload instantly), an attacker can probe whether someone else has a particular file. Many systems deduplicate silently on the server side, after the upload completes, for this reason.
Metadata versus bytes
Keep a row per file in your database: id, owner, object key, size, content type, hash, status (pending, uploaded, processing, ready, failed), and timestamps. Never put the bytes in the database; rows stay small and queries stay fast.
The two stores can disagree. A client can get a presigned URL and never upload, leaving a pending row with no object. An upload can finish while your completion handler is down, leaving an object no row points to. Handle both:
Expire
pendingrows older than the URL lifetime plus a margin.Add a lifecycle rule that aborts multipart uploads left incomplete after a day. Their parts do not appear as objects, but you still pay to store them.
Run a periodic reconciliation that compares rows and objects, deletes objects no row points to, and reports drift. Lifecycle rules cannot do this part: they act on prefixes, tags and age, and know nothing about your database.
Processing after upload
Most files need work before they are useful: thumbnails for images, several resolutions for video, virus scanning, text extraction for search. Do it asynchronously:
The "object created" event goes onto a queue.
Workers pull the job, read the original from storage, write derived files (for example
thumbs/f8a2.../256.jpg) back to storage, and update the metadata row.The status moves to
ready, and the client, which has been polling or listening for a push, shows the result.
Make workers idempotent, since a retried job must overwrite the same derived files rather than create new ones, and send repeatedly failing files to a dead-letter queue. Long processing jobs such as video transcoding follow the job pattern in Multi-Step Processes.
Downloads and delivery
Serving large files through your API servers has the same problem in reverse. Instead:
Presigned download URLs for private files, short-lived, generated after a permission check.
A CDN in front of storage for files many people read, such as public images and popular videos, so most requests are served from an edge location near the user and never reach your origin. See Caching in Depth for how CDN caching behaves.
Range requests. HTTP lets a client ask for part of a file (
Range: bytes=1000000-1999999), and the server answers with206 Partial Content. This powers resumable downloads and video seeking. Streaming video goes further: the file is cut into short segments in several qualities, and the player picks the next segment's quality based on current bandwidth.
Worked example: file sharing with large uploads
Prompt: "Design file upload for a document-sharing product. Files can be up to 5 GB."
A weak answer: "The client POSTs the file to our API, which saves it to storage and writes a row." At 5 GB over a 50 megabit per second connection (40,000 megabits / 50 = 800 seconds), each upload occupies an API server for over 13 minutes, cannot resume, and is lost on every deploy.
A strong answer:
POST /filescreates apendingrow and returns a multipart upload id plus presigned URLs for each 100 MB part: 50 parts for a 5 GB file.The client uploads parts in parallel (four at a time), retrying failed parts and remembering finished ones so it can resume.
The client completes the upload; storage verifies part checksums and emits an event.
A worker scans the file for malware, extracts a preview, and sets status
ready. Until then the file shows as "Processing".Downloads use short-lived presigned URLs; shared public links go through the CDN.
A lifecycle rule aborts multipart uploads still incomplete after 24 hours; a nightly job reconciles rows and objects and deletes orphans.
The strong answer earns points on high-level design because the bytes never touch the API tier, on deep dive and scalability because every failure point (dropped connection, abandoned upload, failed processing) has a defined outcome, and on trade-offs because the upload arithmetic justifies each decision.
Follow-ups to expect
"How do you stop someone uploading 500 GB to a 5 GB limit?" Sign only the part URLs the declared size needs, each bound to its length, and check the final object size before marking the file
uploaded; a mismatch deletes the object."How does the client know processing finished?" Polling a status endpoint, or a push over an existing real-time channel.
"What about a file shared publicly that goes viral?" It is served from the CDN, so the origin sees a small fraction of requests.
"How do you delete a file everywhere?" Remove the metadata first so it disappears for users, then delete the original and derived objects and purge the CDN.
What changes with seniority
Mid-level candidates should keep bytes out of the application tier and use presigned URLs. Senior candidates add multipart and resumable uploads, asynchronous processing, and the consistency problem between metadata and storage. Staff-level candidates also discuss cost (storage classes for rarely read files, egress charges), abuse (malware, quotas) and data deletion obligations.
Mistakes that cost points
Streaming uploads through API servers. Use presigned URLs.
Bytes in the database. Store the key and the metadata; keep bytes in object storage.
Synchronous processing. Never transcode inside the upload request.
No plan for abandoned uploads. Lifecycle rules and reconciliation.
Skipping the arithmetic. File size divided by bandwidth is the number that justifies everything else.
Practice it
In fifteen minutes, sketch photo uploads for a social app on mobile: 5 MB photos, flaky connections, three thumbnail sizes. Decide whether multipart is worth it at that size and how the feed shows a photo that is still processing. Then practice it in a full design: image and file attachments in Design a Real-Time Chat System, where messages must not wait for the file to finish processing.
Practise this in a mock interview
Try what this lesson covers out loud: the AI interviewer asks one of these questions, follows up, and scores your answer.
- Design a URL ShortenerSystem Design · Medium
- Design a Rate Limiter ServiceSystem Design · Medium
- Design Live Score Alert FanoutSystem Design · Medium
- Design a Video Upload and Transcoding PipelineSystem Design · Medium
Read next
- Scaling Reads
Apply the read-scaling moves in order (fix queries, denormalize, add replicas, cache, precompute), check each against a read-rate estimate, and handle replication lag and hot keys.
8 min read
- Scaling Writes
Raise write capacity by writing less, splitting latest state from history, batching behind a durable log, sharding by the write key and splitting hot counters, and size bursts and backpressure with real arithmetic.
8 min read
- Real-Time Updates
Choose between polling, long polling, server-sent events and WebSockets, route each update to the server holding the recipient's connection, and handle ordering, reconnection, missed messages and presence.
7 min read
- Dealing with Contention: When Everyone Wants the Last Seat
Work out how many updates per second a hot row can take, then pick and defend the right fix: pessimistic or optimistic locking, atomic conditional updates, expiring holds, fenced distributed locks, queues or split stock.
8 min read
