Requirements


Functional Requirements:


  • Allow users to tweet messages up to 140 characters.
  • Enable users to follow other users.
  • Allow users to like tweets from other users.
  • Display tweets from followed users in the home feed.
  • Show top K popular tweets in the home feed based on likes and followers.



Non-Functional Requirements:


  1. Daily Active Users (DAU): A realistic target could be around 200 million registered users, with about 50 million daily active users.
  2. Requests Per Second (QPS): For a service like this, we might expect peak QPS to be around 100,000 writes (tweets) and 1 million reads (timeline fetches) during peak times.
  3. Latency: Ideally, user interactions should feel snappy, so we can aim for a latency of under 100 milliseconds for most user actions.
  4. Performance: The system should be designed for high availability and scalability, handling millions of concurrent users and maintaining performance even during peak usage times.


Services + API Design

1) Users Service - for signin+up forgot password etc

2) Tweet Service - to post the tweets and to get tweets with validations.

3) Media Service - to handle media content to upload and retrieve via CDN.




High-Level Design

For the high level design there are different services and patterns we need to use to design this type of system with the given NFR.

Request flow will be like that, given in the diagram

User -> Load Balancer -> Servers (services) (here we will have Authentication + Gateway+ Rate Limiter + and different micro services ) -> Cache(to get recent tweets) -> Db

this will be the design



Detailed Component Design

Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.