System Design Notes
Don’t forget to get your copy of Designing Data Intensive Applications the single most important book to read for system design interview prep!

Facebook/Twitter News Feed

System design interviewers at Big Tech, such as Facebook, Google, and Microsoft often ask the candidates to design Facebook’s News Feed. Twitter’s timeline, Quora’s News Feed and Instagram’s News Feed will have similar architecture.

A News Feed is a collection of the trending stories on the homepage of the web application. It can include status updates, posts, comments, likes, photos, and videos from the user’s followees on the application.

Basic Design Requirements

System design interview questions are almost always open ended, so there’s never a standard answer. Ask your interviewer a set of questions until you have the key features, around which you can formulate an answer.

During a 45-minutes interview, you cannot be expected to produce a high level architecture close to the one Twitter actually uses, but the basics need to be covered well. So here are the key features a basic News Feed architecture should involve:

  • Users should be able to see posts, statuses and app activities from other users, pages and groups they have followed.
  • Users can ‘like’ and comment on posts.
  • The Feeds can be text, images or videos.
  • The News Feed should automatically update with the latest/trending posts.

Design Goals For A Scalable System

  • The system should be scalable to 300M active users.
  • Users can have millions of followers.
  • Assume 6k new tweet requests per second (writes) and 600k requests made by users for fetching their timeline each second (read) on average.
  • A user can see their customized News Feed in real time with minimum latency of no more than 2 seconds.
  • User's posts should be available to millions of followers with low latency of no more than 5 seconds.
  • Up to 800 feeds can appear on the user's timeline.

Three Types Of Timelines

In applications like Facebook and Twitter, there are three different types of timelines:

Home Timeline

This one includes the tweets from all the pages, groups and people that the user has followed.

User Timeline

This timeline displays all the tweets you have made. It appears on your profile page.

Search Timeline

When the user searches a keyword, all the tweets that are related to that particular keyword appear on a timeline. This is the search timeline.

Click here to continue reading this lesson on Medium.