Skip to content
SD-45 · System design

Design a Photo Library

Asked at Senior level45 minutes
Our answers stay hidden until you reveal them.

Design a personal cloud photo library. The phone app backs up every photo the user takes, in the background, and the user can browse their whole library as a timeline on any device, make albums, search by date and place, and share an album or a single photo with friends through a link. Deleted photos go to a trash for 30 days.

There are 500 million users, 100 million of them active each day, uploading 200 million photos a day at about 3 MB each. Every photo is kept forever unless deleted, so storage grows by about 200 PB a year. The hard parts are the bytes (480 Gbit/s of uploads on a holiday peak, from phones on weak networks), never losing a photo and never backing up the same one twice, making thumbnails for every upload, scrolling a library of 50,000 photos without a stutter, and keeping private photos private while sharing works with one tap.

Good questions to ask first

Decide what you would assume for each before you look at ours.

  1. 1Photos only, or videos too?
  2. 2How many uploads?
  3. 3Must the original be kept?
  4. 4How big is a library?
  5. 5Do phones upload the same photo twice?
  6. 6What can be shared?
  7. 7Search?
  8. 8How fast must a new photo show up?

How to spend the 45 minutes

  1. 5minPart 1: Requirements and scope
  2. 5minPart 2: Estimates
  3. 5minPart 3: API and upload protocol
  4. 15minPart 4: Architecture, stage by stage
  5. 15minPart 5: Processing, sync, sharing and trade-offs
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough