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
- Upload: Client → Server → S3
- Resize: Multiple resolutions (thumbnail, medium, large)
- CDN: Cache photos globally
- 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.