注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
本帖最后由 welcoming123456 于 2023-11-9 23:23 编辑
最近在看grokking the system design interview 这本书,里面有一题design twitter search, 书里提到index (word--> tweetID) 如何sharding 提到:
第一种: Sharding based on Words, 提到有如下两个缺点:
1) What if a word becomes hot? Then there will be a lot of queries on the server holding that word. This high load will affect the performance of our service.
2) Some words can end up storing a lot of TweetIDs compared to others, therefore, maintaining a uniform distribution of words while tweets are growing is quite tricky.
. ----第二种: Sharding based on the tweet object, 提到 While querying for a particular word, we have to query all the servers, and each server will return a set of TweetIDs. A centralized server will aggregate these results to return them to the user.
. check 1point3acres for more.
我感觉这本书的意思的是第二种 “Sharding based on the tweet object” 没有第一种的两个缺点 “Sharding based on Words”,所以要选第二种。可是我有两个问题:.1point3acres
1)第二种并没有解决 hot word 的问题啊,而且使情况变得更糟糕了,因为比如一个word短时间内有 1 million的search,第一种会使得一个server有 1 million queries, 而第二种会使所有servers 都有 1 million 的queries, 因为第二种每次都要query 所有servers啊。. 1point3acres
2)第二种每次都要query 所有servers,然后合并,速度要比第一种慢很多吧?
请问大牛们,我的理解对吗?
..
我比较倾向于第一种(Sharding based on Words), 但没想好如何处理 hot word 和 不even distributed 的问题,请问大牛们怎么想?
补充内容 (2023-11-11 13:23 +08:00):
补充:design twitter search 的功能是: 根据输入的单词,搜索并返回包含该单词的所有tweets。 |