Redis-based token client implementation of cluster flow control
#1.188 geöffnet am 5. Dez. 2019
Repository-Metriken
- Stars
- (23.109 Stars)
- PR-Merge-Metriken
- (Keine gemergten PRs in 30 T)
Beschreibung
TokenServer为什么不基于Redis时间窗口来实现呢?或者Redis本身就是一个TokenServer呀! 以“应用名_资源名_规则ID_参数值”作为redis的Key,时间窗口长度(durationInSec)为ttl,创建一条redis记录,创建记录通过 set key value ex ttl nx 指令,确保时间窗口内有且仅有一条有效记录。然后,通过incrBy key count指令进行分布式累积,当累积值超过阀值时,触发限流。 此外,还可以利用redis的分布式和抗压的特点,提长TokenServer的性能。 -- For English user why TokenServer is not based on Redis? or Redis itselt is a good TokenServer! create a redis key like "namespace_resource_flowId_param", ttl=durationInSec, use cmd "set key value ex ttl nx" to make sure in timeWindow only create on record. then use cmd "incrBy key count" for accumulation. if count > threshold then fired block Event.