alibaba/Sentinel

Redis-based token client implementation of cluster flow control

Open

#1,188 opened on Dec 5, 2019

View on GitHub
 (4 comments) (0 reactions) (0 assignees)Java (23,109 stars) (8,150 forks)batch import
area/cluster-flowgood first issue

Description

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.

Contributor guide