Design a News Feed

HardSocialFan-outCachingRankingDistributed SystemsAbout 45 minutes

Design the news feed system for a social network like Twitter or Instagram. Users follow other users and see a ranked list of recent posts. Design for 300M daily active users, each seeing a personalized feed.

How the interview goes

Five phases, and questions the interviewer is likely to ask in each.

  1. 1. Requirements

    • Is the feed chronological or ranked?
    • How many users can a single user follow?
    • What's an acceptable feed staleness (5 seconds? 30 seconds?)
    Show a hint

    Distinguish between active users (need fresh feeds) and inactive users.

  2. 2. High-level design

    • What's your fan-out strategy — push on write or pull on read?
    • How do you handle celebrities (users with millions of followers)?
    • How is the feed stored — pre-computed or generated on the fly?
    Show a hint

    The hybrid approach: push fan-out for regular users, pull fan-out for celebrities.

  3. 3. Deep dive

    • How do you implement the hybrid fan-out for celebrities?
    • What's your cache eviction strategy for pre-computed feeds?
    • How does your ranking algorithm work at query time?
    Show a hint

    Redis sorted sets work well for pre-computed feed storage with score = timestamp.

  4. 4. Scaling

    • How do you handle a post from a celebrity going viral?
    • What happens when a user with 50M followers posts?
    • How do you keep feeds fresh without overwhelming the fan-out system?
    Show a hint

    Celebrities (high follower count) are the hardest case — pull their posts at read time.

  5. 5. Trade-offs

    • Push vs pull fan-out: when is each appropriate?
    • What's the trade-off between feed freshness and compute cost?
    Show a hint

    Fan-out on write: low read latency but high write amplification. Fan-out on read: low write cost but high read latency.

Practice this with an AI interviewer

Write your design doc with live diagrams while the interviewer asks one question at a time and pushes on your choices. Get a scored debrief with what to study next.

Start this interview