知识卡片

问题卡 · 4545.g.8.j.3.b

局部限流要控制状态规模

理解等级:中级

按身份保存令牌桶,需要同步桶表及单桶状态,校验容量、补充量和时间间隔,并清理不再使用的记录。每个实例各自计数时,多副本的全局额度会改变;外置计数也需要原子性和故障策略。示例RemoteAddr只是演示输入,不自动等于稳定、可信的用户身份。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Resilience · 查看原书依据

      First of all, it’s not entirely safe for concurrent use. A production implementation will probably want lock on the record values, and possibly the bucket map. Second, there’s no way to purge old records. In production, we’d probably want to use something like an LRU cache, like the one we described in “Using an LRU

    参考来源

    - 位置:《Cloud Native Go》第09章《Resilience》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch09.xhtml) - 结论依据:按身份保存令牌桶,需要同步桶表及单桶状态,校验容量、补充量和时间间隔,并清理不再使用的记录。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。 - 原始内容:First of all, it’s not entirely safe for concurrent use. A production implementation will probably want lock on the record values, and possibly the bucket map. Second, there’s no way to purge old records. In production, we’d probably want to use something like an LRU cache, like the one we described in “Using an LRU