KatInterview

Design a Photo-Sharing Platform with Social Feed and Discovery

System DesignModel answer
MediumModel answerSystem Designdistributed-systemssocial-networksfeed-generation

Last updated

Build a scalable backend for uploading images, following users, generating personalized feeds, and suggesting new connections to follow.

Problem

You need to architect the backend for a photo-sharing social platform. Users upload images with text descriptions, build a network by following others, browse a personalized stream showing recent content from their connections, and receive suggestions for new accounts to follow.

Core Capabilities

What Users Can Do

  • Upload images along with descriptive text
  • Build their network by following and unfollowing other accounts
  • Browse a personalized stream displaying recent content from accounts they follow
  • Receive algorithmically generated suggestions for new accounts to follow

Performance Targets

  • Availability: Prioritize system uptime for browsing and viewing; temporary inconsistencies are acceptable
  • Speed: Stream retrieval should complete in under 200ms at the 99th percentile; uploads should feel instant to users
  • Scale: The system must gracefully handle accounts with millions of connections without degrading performance for others

Traffic Characteristics

  • Active users daily: 500 million people
  • Image uploads daily: 100 million photos (~1,150/sec average, peaking at ~3,000/sec)
  • Stream requests daily: 5 billion queries (~58,000/sec average, peaking at ~150,000/sec)
  • Typical image size: 2 MB including metadata

Your Task

Design a complete system architecture covering:

  1. Service interfaces: Key endpoints for media upload, network building, stream retrieval, and discovery
  2. Storage strategy: How you'll store content metadata, network connections, and media files; justify database technology choices
  3. Stream generation: Explain your approach to building personalized feeds, comparing different strategies and addressing the challenge of high-follower accounts
  4. Discovery system: Architecture for generating follow suggestions using network topology and user behavior
  5. Performance optimization: Caching layers, data partitioning, and handling uneven load distribution

Focus on concrete technical decisions with quantitative reasoning where applicable.

Hints

Hint 1

Calculate storage and throughput numbers to understand system pressure

Hint 2

Consider whether feeds should be pre-built or assembled on-demand, and what breaks at the extremes

Hint 3

Think about how to handle accounts with vastly different follower counts using different strategies