Katkat

Design a Twitter-like microblogging platform

DisneySoftware Engineer · Onsite

Last updated

This problem tests your ability to design a distributed system capable of handling high-throughput write operations, efficient read-heavy feed generation, and the trade-offs between system consistency and availability.

Problem Statement

Design a microblogging platform similar to Twitter where users can post short updates, follow other users, and view a personalized timeline consisting of posts from the people they follow.

Functional Requirements

  1. Users can post content (max 280 characters).
  2. Users can follow/unfollow other users.
  3. Users can view their personalized timeline (feed) which displays posts from followed users in reverse chronological order.

Non-Functional Requirements

  1. High availability is critical, especially for reading feeds.
  2. Timeline updates should appear with minimal latency (near real-time).
  3. The system must support 100 million daily active users with a peak throughput of 50,000 tweets per second.

Deliverables

Provide an architectural overview covering:

  • API design (key endpoints and request/response structure).
  • Database schema design (SQL vs. NoSQL considerations).
  • Feed generation strategy (Push vs. Pull models) and how to handle "celebrity" users with millions of followers.
  • Caching strategies to optimize read performance.

Scaling Assumptions

  • Average user follows 100 people.
  • Fan-out operations should complete within 5 seconds for 95% of users.

Hints

Hint 1

Consider the trade-off between calculating the feed at read-time versus pre-computing it at write-time.

Hint 2

Think about how the 'fan-out' process differs for a typical user versus a celebrity account with 10 million followers.

Hint 3

Identify which database operations are write-intensive versus read-intensive and choose storage engines accordingly.

Follow-up questions

  • How would you handle global distribution if users in different geographic regions expect sub-100ms latency?
  • If we introduce a 'retweet' feature, how does that impact your data model and feed generation logic?
  • What specific metrics would you monitor to identify bottlenecks in the fan-out service?