Home System Design Twitter
Post
Cancel

System Design Twitter

Define the problem

  • making problem clearer and more concrete
  • only design core features of Twitter instead of everything.
    • the whole product should allow people follow each other and view others feeds.
  • registration, moment, security is out of the scope

High-level solution

  • don’t jump into all the details immediately
  • to divide the whole system into several core components
    • frontend/backend, offline/online logic
  • following two things:
    • Data modeling:
      • define user object and feed object
      • releations are also necessary
    • How to serve feeds
      • way is to fetch feeds from all the poeple you follow and render them by time.

Detail questions

  • Q. When users followed a lot of people, fetching and rendering all their feeds can be costly. How to improve this?
  • A.
    • infinite scroll feature, to fetch the most recent N feeds instead of all of them.
    • consider cache, which might also be helpful to speed things up.
  • Q. How to detect fake users?
  • A.
    • features(e.g., registration date, the number of followers, the number of feeds), build a machine learning system to detect if a user is fake
  • Q. Can we order feed by other algorithms?
  • A. (should clarify)
    • How to measure the algorithm?
      • by the average time users spend on Twitter
      • users interaction like favorite/retweet.
    • What signals to use to evaluate how likely the user will like the feed?
      • Users relatio nwith the author, the number of replies/retweets of this feed,
  • Q. How to implement the @feature and retweet feature?
  • A. We can simply store a list of user IDs inside
  • Clicking each topic will direct you to all related tweets
  • high-level approach first
  • two subproblems:
    • How to get trending topic candidates?
      • the most frequent hashtags over the last N hours.
      • the hottest search queries.
      • the recent most popular feeds and extract some common words or phrases
    • How to rank those candidates?
      • rank based on frequency
      • reply/retweet/favorite numbers, freshness.
      • personalized signals like whether there are many follows/followers talking about the topic.

Who to follow

  • How to scale the system when there are millions/billions of users?
  • How to evaluate the system?
  • How to design the same feature for Facebook (bi-directional relationship)

Moments

  • show you a list of intersting topics for different categories

Reference

This post is licensed under CC BY 4.0 by the author.

Interview 준비

System Design Youtube