Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 45

Design a private photo library

Advanced · 45 min · Storage & data modeling

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

Done on paper? Compare with the worked approaches