8000 GitHub - MaxBill/redis-limiter: SpringBoot中Redis+Lua 令牌桶算法限流实践
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MaxBill/redis-limiter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redis实现的令牌桶算法限流

说明

  • 内容参考Spring Gateway的RedisRateLimiter 以及 request_rate_limiter.lua脚本
  • 使用Redis + Lua自定义脚本的方式实现一个令牌桶算法,对指定接口请求速率的控制
  • 封装了基于注解实现的令牌桶限流方法,可针对接口/用户/IP 速率限制

使用场景

  • Gateway本身做了限流配置,但是某个接口要实现更细粒度的速率控制
  • 未使用Gateway,或是不想在网关做控制
  • ...

测试

  • 运行项目 mvn spring-boot:run
  • 访问 http://localhost:8080/limiterByPathhttp://localhost:8080/limiterByUserIdhttp://localhost:8080/limiterByIp
  • 可多次刷新页面查看效果

About

SpringBoot中Redis+Lua 令牌桶算法限流实践

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 82.9%
  • Lua 17.1%
0