如果用 DynamoDB 设计排行榜,GSI 应如何建模?scatter-gather 的代价是什么?
If using DynamoDB for a leaderboard, how would you model it with a GSI, and what are the costs of scatter-gather?
题目类型: 技术面试题
这是一道技术面试题,常见于澳洲IT公司面试中。
难度: hard
分类: System Design
标签: DynamoDB, GSI, scatter-gather
参考答案摘要
答案 可用 GSI:partition key 选 player-id(或按榜单/区域分片),sort key 选 score,实现按分数范围查询。若需要全局 Top N,可能要对多个分区分别查询(scatter)再在服务端合并(gather),这会增加读放大、网络开销与服务端计算复杂度;当流量高到单一索引无法承载时才考虑更复杂的分区策略,并配合 DynamoDB Streams 做变更捕获与异步...
本题提供 STAR 原则详细解答和技术解析,登录匠人学院学习中心即可查看完整答案。