You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Approach wiki:https://www.yuque.com/ximu/sentinel-golang/em55x6
集群流控这个大概就是
client 侧:提供直接从token server(redis) 取token或则是通过步长形式取token,本地 + token server结合。
Server侧:redis的incr来控制token,token的重置是通过集群中选一个节点做 expire。redis token key是基于 resource + 当前毫秒时间在统计周期上的起始时间;这样直接就在key上面做一个类似于滑动窗口,对齐时间自动过期。key的删除就在集群选一个节点执行expire,选择策略就是 incr的返回值 == tokencoun 的实例。
Server侧还有个滑动窗口思路(基于zset来做),key用resource,score存时间戳,这种应该可以避免token重置问题(在pipeline里面直接删掉在当前时间往前统计周期的时间戳)。
大伙可以看下这个思路,提一些comments
Draft code: #369
Beta Was this translation helpful? Give feedback.
All reactions