Design a photo-sharing service like Instagram
MediumConceptSocial Platforms
Answer
Requirements: users upload photos with captions, follow other users, and view a feed of photos from people they follow. The system is heavily read-dominated, and uploaded photos must never be lost.
- Upload: clients upload directly to object storage with a pre-signed URL; an upload event triggers workers that generate thumbnails and several resolutions.
- Metadata: photo ID, owner, caption and storage keys live in a database sharded by user ID, using globally unique, time-sortable IDs such as Snowflake IDs.
- Serving: images are delivered through a CDN; the feed is assembled from followed users' recent photo IDs, as in a news feed design.
- Trade-off: pre-generating several image sizes costs storage and processing at upload time, but makes every later view faster and cheaper in bandwidth.
More in Social Platforms
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Design a photo-sharing service like Instagram | Concept | Medium | Read the answer to Design a photo-sharing service like Instagram | |||
| 2 | Design a typeahead (search autocomplete) system | Concept | Medium | Read the answer to Design a typeahead (search autocomplete) system | |||
| 3 | Design a news feed system | Concept | Hard | Read the answer to Design a news feed system | |||
| 4 | Design a chat application like WhatsApp | Concept | Hard | Read the answer to Design a chat application like WhatsApp |