SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 45
Design a private photo library
People want every photo they take backed up automatically and available on their phone, tablet and laptop. They scroll years of photos by date, group them into albums, and search for things like "dog on the beach". Nothing is shared publicly; this is their private library.
Requirements
- Automatically back up new photos from phones, resuming after interruptions and never storing the same photo twice for one user.
- Browse the whole library by date with thumbnails that load as fast as the user scrolls, and open the full-resolution original.
- Create albums (a photo can be in many) and delete photos; changes appear on all of the user's devices.
- Search by date, place and detected content.
Constraints and assumptions
- 50 million users with an average of 4,000 photos each at 3 MB, so about 600 PB of originals today.
- Each user adds about 20 photos a week: roughly 140 million uploads a day, about 1,600 per second on average.
- About 15% of upload attempts are photos the service already has for that user (reinstalls, second devices, re-exports).
- A screen of 60 thumbnails should render within 200 ms; a library can hold up to 500,000 items.
- An edit on one online device should appear on the user's other online devices within 30 seconds.
Out of scope for the first sketch
Sharing photos with other people or a social feed · Photo editing tools · Training the image classifier (assume one exists)
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a private photo library
Finish your first sketch before answering these. Cross out freely.
- A user reinstalls the app and it tries to back up 20,000 photos that are already stored. What does that cost your system?
- A user signs in on a new laptop with a 200,000-photo library. What does the laptop download first, and how long until it is usable?
- A photo is deleted on the phone while a laptop that has been offline for a week adds it to an album. What does each device show after both sync?
- Two different users upload the same image. Should you store it once? What does that do to deletion and privacy?
- Most photos are never opened again after the first month. How do you cut storage cost without making old photos painful to open?
Compare afterwards: worked approaches and reading at sketchbook /questions/photo-library/review