Design Instagram: Feed Fan-Out, Celebrity Accounts and Photo Storage
Company: DoorDash
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
Design Instagram: users post photos with captions, follow other users, and scroll a home feed of recent posts from the accounts they follow. In about 40 minutes, the interviewer expects you to estimate the load (QPS), lay out the main data structures, and go deep on three topics: fan-out on write versus fan-out on read for building feeds, accounts with very many followers (the celebrity problem), and storing photos separately from their metadata.
```hint Who pays for a post
Compare the work done when a user posts with the work done when a follower opens the feed, for an account with a hundred followers and for one with a hundred million.
```
```hint Bytes versus rows
Think about how differently photo bytes and post records are written, read, changed and cached.
```
### Clarifying Questions
- How many daily active users, posts per day and feed opens per user should the design support?
- Is the feed reverse chronological, or ranked?
- Which features are in scope besides posting, following and the feed: likes, comments, stories, search?
- How soon after a post must it appear in followers' feeds, and how fast must the feed load?
- What photo sizes are uploaded, and which resolutions must be served to different devices?
### What a Strong Answer Covers
- Requirements and estimates for QPS and storage, including the read-to-write ratio
- A data model for users, follows, posts and precomputed feeds, with partition keys
- Fan-out on write versus on read, and a hybrid for celebrity accounts
- An upload and serving path that keeps photo bytes in object storage behind a CDN and metadata in a database
- Caching, feed pagination, and handling a fan-out backlog
- Monitoring, and the trade-offs behind each choice
### Follow-up Questions
- A celebrity with tens of millions of followers posts. Walk through what happens on write and on the next feed reads.
- A user unfollows an account. How do that account's posts leave the user's feed?
- How would you add ranking without losing the precomputed feed's latency?
- A data center holding part of the feed cache is lost. What do users see, and how does the system recover?
Overview: A senior system design question asking for an Instagram-style photo sharing service with posting, following and a home feed. It tests load estimates, data modeling, fan-out on write versus fan-out on read, handling celebrity accounts, and keeping photo bytes separate from post metadata.
Read the full DoorDash Software Engineer interview experience this question came from