Design a Social Media Platform Like Instagram: Uploads, Feeds and Hashtag Search
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Other
Design a social media platform similar to Instagram. The system should manage the delivery and retrieval of posts, feeds and search results in real time.
Functional requirements:
1. Users upload images and videos with optional captions and hashtags.
2. Users follow and unfollow other users to subscribe to or stop receiving their updates.
3. Each user gets a personalized home feed built from the accounts they follow.
4. Users search for posts by caption keywords and by hashtag.
Walk through your requirements, capacity estimates, data model, API, high-level architecture and the main request flows.
```hint Start with the numbers
Estimate posts per day, storage per year and the read-to-write ratio. The ratio tells you which path deserves the most work.
```
```hint Watch the large accounts
Ask what your feed strategy costs when one author has tens of millions of followers, and what it costs a user who follows thousands of accounts.
```
### Constraints & Assumptions
- Availability matters more than consistency. Eventual consistency is acceptable.
- Pages load in under 300 ms.
- The service targets 99.9% uptime.
- These non-functional requirements are a starting point. Add any others the system needs.
### Clarifying Questions to Ask
- How many daily active users are there, and how often does a typical user post?
- What is the average size of a post, and how long can uploaded videos be?
- Is the home feed reverse-chronological, or does it need ranking?
- How quickly must a new post appear in followers' feeds and in search results?
- Which features are out of scope, such as messaging, comments, stories or image editing?
### What a Strong Answer Covers
- Capacity estimates for storage and for read and write QPS, and the design choices they lead to.
- A data model and API that cover all four functional requirements, including follow and search.
- Where media files and post metadata are stored, and how the upload stays consistent when one step fails.
- A feed generation strategy with a clear plan for accounts that have very large followings.
- How the search index and caches stay up to date, and how the CDN and caching meet the latency and availability targets.
### Follow-up Questions
- How would you add ranking to the home feed while staying inside the 300 ms budget?
- A user follows a new account. How do that account's recent posts reach the user's feed, and what happens on unfollow?
- A post is deleted. How do you remove it from feeds, search results and CDN caches? What changes when an account goes private instead?
- What changes if the platform must serve users from several regions?
Overview: Design a photo and video sharing platform that supports media uploads, following other users, a personalized home feed and search by caption or hashtag. It tests capacity estimation, storage choices, feed fan-out for large accounts, search indexing and caching for a read-heavy workload.