知识卡片
限流计数需要快速存储
共享内存存储可让多个限流实例读取同一维度的计数,并通过过期清理窗口状态。INCR 和 EXPIRE 分别表达自增与到期,但把多个调用拼在一起不自然等于一次原子判断,仍需处理并发。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
- · 第04章 限流器
原书出处 · 1 处
- 限流器 · 查看原书依据
Where shall we store counters? Using the database is not a good idea due to slowness of disk access. In-memory cache is chosen because it is fast and supports time-based expiration strategy. For instance, Redis [11] is a popular option to implement rate limiting. It is an in-memory store that offers two commands: INCR and EXPIRE. •INCR: It increases the stored counter by 1. •EXPIRE:
参考来源
- 位置:《System Design Interview – An insiders guide, Second Edition》第04章《限流器》(来源项目 book-sources;源文件:extracted/System Design Interview – An insiders guide, Second Edition/_epub-src/text/part0009_split_002.html)
- 结论依据:原文在该位置给出所述对象、机制或比较,支持本卡的解释;原书未展开的实现不作为已证明结论,算式与一致性边界在正文明确限定。
- 原始内容:Where shall we store counters? Using the database is not a good idea due to slowness of disk access. In-memory cache is chosen because it is fast and supports time-based expiration strategy. For instance, Redis [11] is a popular option to implement rate limiting. It is an in-memory store that offers two commands: INCR and EXPIRE. •INCR: It increases the stored counter by 1. •EXPIRE: