Skip to content
We areTOP 1%

Design a news feed system

HardConceptSocial Platforms
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

Requirements: users publish posts and see a feed of recent posts from the people they follow, loaded quickly and possibly ranked. Reads vastly outnumber writes.

  • Components: a post service and store, a social graph service for follow relationships, a fan-out service, a feed cache holding a list of post IDs per user (for example, Redis lists), and a feed service that hydrates IDs into full posts.
  • Fan-out on write (push): when a user posts, insert the post ID into every follower's cached feed; reads are fast, but writes are expensive for accounts with millions of followers.
  • Fan-out on read (pull): assemble the feed at read time from followed users' posts; writes are cheap, reads are slow.
  • Trade-off: most designs use a hybrid, pushing posts from ordinary users and pulling celebrities' posts at read time, then merging the two.

More in Social Platforms

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account