KatInterview

Build a photo-sharing platform architecture

System DesignModel answer
MediumModel answerSystem Designsystem-designdistributed-systemsscalability

Last updated

Architect a distributed system for uploading photos, following users, and serving personalized image feeds at scale with low latency.

You're tasked with architecting a photo-sharing platform that lets users post images, build a following, and browse a personalized stream of content from accounts they follow.

Core Capabilities

Your system must support:

  • Photo publishing: Users upload images with text descriptions
  • Social graph: Users establish and break follow relationships
  • Personalized stream: Users see recent images from accounts they follow
  • User galleries: Each profile displays all images posted by that account

Performance & Scale Targets

  • Availability: Individual service failures shouldn't bring down the platform
  • Throughput: Support millions of simultaneous users with high request volumes
  • Speed: Photo uploads must be reliable; stream loads should complete in under 200ms
  • Data integrity: User profiles require strong consistency; streams can tolerate brief staleness

Design Scope

Provide:

  1. Architecture overview describing major components and their interactions
  2. Core API contracts for the main features
  3. Database choices and schema structure (explain SQL vs. NoSQL trade-offs)
  4. Image storage and content delivery strategy

Scale Parameters

Work with these assumptions:

  • 100 million users active daily
  • 5 million photos published each day
  • Workload heavily skewed toward reads over writes

Focus on the stream and upload flows. Reactions, nested replies, ephemeral content, and direct messaging are out of scope.

Hints

Hint 1

Start with capacity math—calculate average and peak requests per second for uploads, stream views, and image fetches to drive storage and caching decisions

Hint 2

The read-to-write ratio matters: decide whether to compute streams at write time (fan-out on write) or read time (fan-out on read), and consider a hybrid for accounts with massive followings

Hint 3

Separate binary data from metadata—store image files in object storage with CDN delivery, and use different databases for structured data like posts, relationships, and precomputed streams