Open bigstar119 opened 4 years ago
Considering performance and flexibility, Redis may not satisfy all scenarios for cluster flow control. However, it's encouraged to introduce a token client implementation based on Redis (lua script) so that users who leverage Redis as the token server could also use Sentinel (and benefit from advanced features and open-source ecosystem of Sentinel). Contributions are welcomed!
我们正在开发该功能,通过lua脚本定位滑动窗口和数据统计,后续可以提PR吗
我们正在开发该功能,通过lua脚本定位滑动窗口和数据统计,后续可以提PR吗
@binecy Contributions are welcomed! This can be an individual token client module. You may refer to the SPI hierarchy of the token client.
ok
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.