Redis-based token client implementation of cluster flow control
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
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
Research direction
Start by reviewing the existing TokenServer flow-control path and the Redis commands named in the issue: SET with EX/NX and INCRBY. Determine where a Redis-backed client would integrate and how threshold breaches should trigger the block event. Done means the proposed Redis-based cluster flow-control behavior is implemented and verified against the existing TokenServer expectations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100