Design Instagram (Photo Sharing Platform)
Instagram is a global photo sharing and social media platform hosting billions of user-uploaded images and custom activity feeds.
1. High-Level Design
Instagram requires a highly optimized media ingestion pipeline alongside a fast, pre-computed timeline generator.
Upload Path: Client ---> API Gateway (Presigned URL) ---> AWS S3 Storage
Metadata Path: Client ---> Feed Service ---> PostgreSQL (Metadata) ---> Redis Pre-computed FeedComponents
1. Media Ingest Gateway: Authenticates requests and returns a presigned S3 upload URL. The client uploads images directly to S3, bypassing application servers.
2. Media Processor: Triggered by S3 upload notifications, it compresses images and generates multi-resolution thumbnails.
3. Feed Service: Pre-computes activity timelines. It uses a Push Model (fan-out on write) for average users, publishing their photo directly to friends' feeds in Redis. It uses a Pull Model (fan-out on read) for popular/celebrity profiles to avoid write amplification.
2. Potential Deep Dives
- Media Cache Eviction:
Use CDN edge networks (CloudFront) to cache hot images. Configure a Least Recently Used (LRU) policy on CDN edges to prune cold images.
- Database Sharding:
Shard PostgreSQL metadata tables using user_id as the sharding key. This ensures all photo records for a single user live on the same physical shard.
3. References & Tech Blogs
Related Topics
Expand your knowledge by learning about adjacent concepts in system design.
Design a URL Shortener (TinyURL)
Build a high-throughput shortener analyzing base58 encodings and database sharding.
Networking Essentials
Learn the important parts of networking that you'll need to know for your system design interviews
API Design
Learn about API design for system design interviews
Cheat Sheet Utility
View and print a concise system design reference card.