Design the backend for Instagram - a media-first social platform with 2 billion monthly active users. It handles one of the largest media pipelines in the world. Your design must cover:
- Photo & video upload pipeline - users upload photos and short-form videos (Reels, up to 90 seconds). Each upload is resized into multiple resolutions, stripped of EXIF data, and stored durably. The system handles 100 million uploads per day.•Feed generation - the home feed mixes posts from followed accounts and recommended content, ranked by an ML model (engagement prediction). Feed must load in < 500 ms.•Stories - ephemeral 24-hour content served from edge caches. Stories from close friends are prioritized.•Explore / Reels - entirely recommendation-driven feeds. A candidate generation → ranking → re-ranking pipeline selects content, personalized per user.•Direct Messages (DMs) - E2E-encrypted messaging with photo/video sharing support.•Engagement features - likes, comments, saves, shares. Like counts are eventually consistent (it's okay if the count is off by a few for a few seconds).
The key challenge is the sheer volume of media processing + storage combined with real-time feed personalization.
Design Instagram's photo/video sharing platform - feed generation, Stories, Reels, and Explore at 2 B users. Build this architecture under realistic production constraints, then validate tradeoffs in the design lab simulation.
Request path: The solution keeps ingress, service logic, and stateful dependencies separated so each layer can scale independently.
Reference flow: Web Clients -> DNS -> CDN Edge -> Load Balancer -> Core Service -> Primary NoSQL DB -> Redis Cache -> Message Queue