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:


  • Scalability - Needs to handle large amounts of users, increase or decreases in loads
  • Consistency - latest tweets need to be able to be accessed by users; plays a critical role in determining popularity, tracking likes, etc.


API Design

GET /

POST //create

POST///follow

POST///like

DELETE /

GET //recommended?results_per_page_20&page=1

GET //feed?results_per_page_20&page=1



High-Level Design

Users are able to interact with the server through load-balancer managed clusters that are distributed through a CDN. Tweets are stored and updated in a database which is fanned out via websockets back to users




Detailed Component Design

Websockets -- may provide better consistency but potential tradeoff for availability at peak usage times. Ensures low latency. May be able to be mitigated via redis cache.


Load balancer - ensures that peak usage times do not affect consistency or availability. Does increase horizontal scaling complexity