Skip to content

First principles · 4 of 4

Where the files go

Step 1 · The pattern

Uploads go through the app

Shoppers check out (150 ms each), and now and then someone uploads a photo of an item. The upload goes to the app server, which receives the file and writes it to object storage. The app has 6 workers, and a few uploads barely register. (All numbers are illustrative.)

  • checkout
  • photo upload
  • done

In short

Where the files go: how it works and how it breaks

A checkout is a few kilobytes and takes a fraction of a second; a 5 MB photo from a phone takes seconds to arrive, and if it goes through the app servers it holds a worker for that whole time. A few uploads are fine. On a busy evening the uploads take every worker, and ordinary requests such as checkouts queue behind them and fail. The usual design keeps the bytes away from the app: the app checks who is asking and hands back a short-lived signed link, the phone uploads straight to object storage with it, and the files are served to other users through a CDN. The app's part now takes milliseconds. Keep the links short-lived and scoped to one object, since anyone holding a link can use it until it expires.

What this simulation simplifies

  • Every upload takes exactly three seconds here; real ones vary with file size and the phone's connection.
  • Object storage is shown with no limit; real services have per-request and per-prefix rates, far above what one app tier handles.
  • Reading files back (through a CDN) is described but not animated.

How this comes up in interviews

"Design photo uploads for an app with millions of users. Where do the bytes go?"

Then they ask

  1. How does the app control who can upload what?
  2. What happens to a half-finished upload?
  3. How do you serve the photos quickly worldwide?

A strong answer covers

  • Keep large uploads off the app servers: they hold a worker for the whole transfer.
  • The app authorises and returns a short-lived signed link scoped to one object.
  • The client uploads directly to object storage; multipart or resumable for large files.
  • Record the file's key after storage confirms; clean up orphaned files.
  • Serve through a CDN; generate thumbnails asynchronously.

Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.

On one page: the track cheat sheet.

Last reviewed: Official documentation

Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.