Katkat

Design a Scalable News Feed

RipplingSoftware Engineer · Onsite

Last updated

This problem tests your ability to design a high-scale feed delivery system, specifically focusing on the trade-offs between 'push' (fan-out) and 'pull' (fan-in) models for delivering content to users.

Design a Scalable News Feed

Design a social media news feed system where users can post updates (text/images) and see a feed of updates from the people they follow.

Functional Requirements

  1. Users can post content.
  2. Users can follow other users.
  3. Users can view their personalized news feed.

Non-Functional Requirements

  1. Scale: The system must support 100 million daily active users.
  2. Latency: Feed retrieval should be under 200ms.
  3. Consistency: Eventual consistency is acceptable for feed updates.

Task

  • Propose an API design for posting content, following users, and fetching the feed.
  • Define the data model (e.g., SQL vs. NoSQL choices).
  • Design the architecture for feed generation. Explain how you would handle 'celebrity' users with millions of followers versus regular users.
  • Discuss your caching strategy and how to handle pagination.

Hints

Hint 1

Consider the difference in load between a user with 50 followers and a celebrity with 5 million followers.

Hint 2

Think about the trade-offs between pre-computing the feed upon login (pull) versus pre-computing the feed at the moment of post creation (push).

Hint 3

Evaluate how to use a combination of both strategies (hybrid approach) to optimize performance for different types of users.

Follow-up questions

  • How would you handle media uploads (images/videos) within the posts?
  • If the feed ranking needs to be smarter (e.g., ML-based relevance), how would that change your system architecture?
  • How would you ensure high availability and partition your data if a single database instance cannot hold all user activity?