Social Media (Instagram)
Overview
Designing a Social Media platform (Instagram) combines photo/video storage, news feed, real-time features, and discovery. The question tests your ability to handle media uploads at scale, feed generation (push vs pull), stories (ephemeral content), and explore/recommendations. This design matters in interviews because it's a well-known product with multiple subsystems—each with its own scaling challenges. Demonstrating you understand CDN for media, fan-out for feed, and how to design for both read-heavy (feed) and write-heavy (upload) workloads shows you can architect complex social products. Meta and other companies ask this to see if you can reason about the full stack from client to storage.
Requirements
Functional
- Upload photos/videos with captions
- Follow users, view feed of posts
- Stories (24-hour ephemeral)
- Like, comment, direct message
- Explore/discover content
- Search users and hashtags
Non-Functional
- Low latency — feed load <200ms
- High availability — 99.99%
- Media delivery — CDN, multiple resolutions
- Scalability — billions of posts, millions of uploads/day
Capacity Estimation
Assume 1B users, 100M posts/day. 50M stories/day. 10B feed reads/day. Media: 100M * 5MB = 500TB/day upload.
Architecture Diagram
Component Deep Dive
Media Upload Service
Accepts uploads, stores in object store. Generates thumbnails, multiple resolutions. Async processing.
Feed Service
Generates feed from followed users. Push (pre-compute) or pull. Ranking by engagement.
Story Service
Ephemeral content, 24h TTL. Separate pipeline. High write, high read, auto-delete.
CDN
Serves images/videos. Multiple resolutions. Reduces origin load.
Search/Discovery
Elasticsearch for users, hashtags. Recommendation engine for explore.
Notification Service
Push for likes, comments, new followers. Real-time delivery.
Database Design
Posts, users, follows in PostgreSQL/Cassandra. Media URLs in object store. Feed in Cassandra (push) or computed (pull). Stories in Redis with TTL or Cassandra with TTL.
API Design
| Method | Path | Description |
|---|---|---|
POST | /api/posts | Upload post. Multipart. Returns post_id. |
GET | /api/feed | Get feed. Paginated. |
POST | /api/stories | Post story. Expires in 24h. |
GET | /api/explore | Discover content. Personalized. |
Scalability & Trade-offs
- Feed: Push for most users; pull for celebrities (avoid write amplification).
- Media: Multiple resolutions increase storage; single resolution + on-demand transcoding reduces storage, adds latency.
- Stories: Separate storage with TTL vs reusing post table. TTL simplifies cleanup.
Related System Designs
News Feed System
The News Feed system design (like Facebook or Twitter) is a classic interview question that tests your understanding of ...
InfrastructureURL Shortener (TinyURL)
The URL Shortener (TinyURL-style) system design is a classic interview question that tests your understanding of distrib...
InfrastructureRate Limiter
A Rate Limiter system design question tests your understanding of distributed systems, consistency, and real-time decisi...