当单个 Redis 节点无法承载热门排行榜 QPS 时,如何对排行榜缓存做分片(sharding)?为什么用 score 作为 shard key 会带来查询困难?
When a single Redis node cannot handle a popular leaderboard’s QPS, how do you shard the leaderboard cache? Why does using score as a shard key make certain queries difficult?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: hard
分类: system-design, caching
标签: sharding, redis, score-shard-key, ranking-query
参考答案摘要
TL;DR 热门榜单可能使 QPS 超过单个 Redis 节点阈值,需要对缓存进行分片。可以按 score 做 shard key 来优化 TopN 与周边排行查询,但会导致“按 player 查 rank/score”变得困难,因为同一个 player 的位置取决于 score 并可能频繁迁移。 按 score 分片的好处 适合 Top 10 查询(高分段集中在少数 shard)。 适合周边排名...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。