Design a Scalable News Feed
RipplingSoftware Engineer · OnsiteLast 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
- Users can post content.
- Users can follow other users.
- Users can view their personalized news feed.
Non-Functional Requirements
- Scale: The system must support 100 million daily active users.
- Latency: Feed retrieval should be under 200ms.
- 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?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.