限流YML配置
ratelimiter:instances:backendA:# 限流周期时长。 默认:500纳秒limitRefreshPeriod: 5s# 周期内允许通过的请求数量。 默认:50limitForPeriod: 2
先写Controller
/*** 限流* @return*/@GetMapping("/limiter")@RateLimiter(name = "backendA")public CompletableFuture<String> RateLimiter() {log.info("********* 进入方法 ******");//异步操作CompletableFuture<String> completableFuture = CompletableFuture.supplyAsync((Supplier<String>) () -> (paymentFeignService.index()));log.info("********* 离开方法 ******");return completableFuture;}
JMeter压测
- 线程数 - 5