Skip to main content

Design Instagram

Problem

Design Instagram with photo upload, news feed, stories.

Requirements

  • Upload photos/videos
  • News feed (following users' posts)
  • Stories (24-hour expiry)
  • Scale: 1B users, 95M photos/day

Key Components

Photo Storage

  1. Upload: Client → Server → S3
  2. Resize: Multiple resolutions (thumbnail, medium, large)
  3. CDN: Cache photos globally
  4. URL: https://cdn.instagram.com/abc123/photo.jpg

News Feed

  • Similar to Twitter (fanout-on-write for regular, fanout-on-read for celebrities)
  • Cache in Redis (sorted set)

Stories

  • Store in Redis with 24-hour TTL (auto-expire)
  • Key: story:user_id → list of story URLs

Next: Design YouTube.