SD-45 · Back to the write-up
Design a Photo Library
Phones hash each photo and upload only new ones, straight to object storage; workers make thumbnails off the upload path, and a CDN serves the timeline.
Follow a request
Back up a photo
Skip a duplicate
Make thumbnails
Scroll the timeline
Sync another device
Devices
Edge
Services
Data
Phone appBackup + browse
Other deviceTablet or web
CDNThumbnails
Library APIStateless
QueueJob per photo
Object storageOriginals + thumbs
Metadata DB16 shards by user
Image workersThumbnails, EXIF
The numbers, at a glance
3 skipped by hash7 uploaded
219 PBY1
438 PBY2
657 PBY3
876 PBY4
1.1 EBY5
8% thumbnails92% originals
A backup, in order
A duplicate stops after step 3. Thumbnails are made after the 201, off the upload path.
Phone
Library API
Metadata DB
Object storage
Queue
Image worker
1 POST /v1/uploads { sha256 }
2 hash exists?
3 no
4 201 + part URLs
5 PUT part
6 200 etag
7 POST /complete
8 check hash
9 row + change
10 process job
11 201 backed up
12 pull job
13 read, write thumbs
RequestResponseAsync, does not block
How the bytes get to storage
The decision this question is really about.
POST 3 MB
app server streamsresize inline
drop = start over
+ Server sees every byte.− 480 Gbit/s through servers.
signed URL
PUT whole file
50 MB RAW drops at 90%
+ Bytes skip our servers.− No resume, no dedupe.
SHA-256 check
8 MB signed partscommit checks hash
queue → thumbnails
+ Skips duplicates; resumes parts.− Three calls per photo.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Phone
App server
Object storageDatabase
Phone
Load balancerLibrary API
Object storageMetadata DB
Phone
Load balancerLibrary APIQueue
Object storageShards by userImage workers
PhoneOther devices
CDNLibrary APISync notifier
Object storageShards by userImage workersSearch
Was this walkthrough useful?Your vote tells us what to improve next.