16 Design a news feed

 

This chapter covers

  • Designing a personalized scalable system
  • Filtering out news feed items
  • Designing a news feed to serve images and text

Design a news feed that provides a user with a list of news items, sorted by approximate reverse chronological order that belong to the topics selected by the user. A news item can be categorized into 1–3 topics. A user may select up to three topics of interest at any time.

This is a common system design interview question. In this chapter, we use the terms “news item” and “post” interchangeably. In social media apps like Facebook or Twitter, a user’s news feed is usually populated by posts from friends/connections. However, in this news feed, users get posts written by other people in general, rather than by their connections.

16.1 Requirements

These are the functional requirements of our news feed system, which as usual we can discuss/uncover via an approximately five-minute Q&A with the interviewer.

16.2 High-level architecture

16.3 Prepare feed in advance

16.4 Validation and content moderation

16.4.1 Changing posts on users’ devices

16.4.2 Tagging posts

16.4.3 Moderation service

16.5 Logging, monitoring, and alerting

16.5.1 Serving images as well as text

16.5.2 High-level architecture

16.6 Other possible discussion topics

Summary