← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 034 · Databases and storage

Design a Photo Sharing App

Medium 50 min

Design the backend for a mobile photo sharing app. Users upload photos with a caption, follow other users and scroll a home feed of recent photos from the accounts they follow. The app has 50 million daily active users who upload 5 million photos a day and load their feed about 30 times a day each. Photos must show up in followers' feeds within a minute and load quickly on slow mobile networks anywhere in the world.

Functional requirements

  • Upload a photo with a caption; the app shows it in several sizes
  • Follow and unfollow other users
  • Scroll a home feed of recent photos from followed accounts, newest first
  • Like a photo and see like counts

Non-functional requirements

  • Feed pages load in under 300 ms at p95, excluding image download
  • Uploaded photos are never lost once the upload succeeds
  • A new photo appears in followers' feeds within 1 minute
  • Images load fast worldwide on mobile connections

Constraints and scale

  • 50 million daily active users, peaking at about 30,000 feed requests per second
  • 5 million uploads a day at 3 MB average, about 15 TB of originals per day
  • Median user follows 150 accounts; a few celebrities have over 10 million followers

You will practise

  • Separate large binary data (object storage and CDN) from metadata (database)
  • Generate image variants asynchronously with a queue and workers
  • Choose between fan-out on write and fan-out on read for feeds, including celebrity accounts
Show 2 hints
  1. Should the upload request wait while the server produces three resized copies of the image?
  2. Copying a celebrity's post into 10 million feeds takes a while. What could you do for those accounts instead?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A celebrity with 30 million followers postsAn account with 30 million followers posts a photo during peak hours. Fan-out workers start writing the photo ID into 30 million cached feeds and the queue backs up behind them.

Run them from the workspace once your design is in place.