怎么对整个OpenFeign的客户端接口进行QPS总量限流
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
**现在有这样一个需求, 我在A服务中调用B服务, 但是B服务要求每秒总请求不能超过60QPS,
例如,如下Feign客户端, 我应该怎么写才能实现对类中所有方法的总QPS进行限制
还有一种按分钟的, 每分钟不能超过2000QPS应该怎么实现**
```
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* 用户服务
*
*/
@FeignClient(contextId = "remoteUserService", value = "ruoyi-system")
public interface RemoteUserService
{
@GetMapping(value = "/user/info/{username}")
public Object getUserInfo(@PathVariable("username") String username);
/**
* 通过用户名查询用户信息
*
* @param username 用户名
* @return 结果
*/
@GetMapping(value = "/user/info/{userId}")
public Object getUserInfo(@PathVariable("userId") Long userId);
}
```
**我尝试在接口上添加
@SentinelResource("remoteUserService")
然后再nacos中配置, 不起作用**
```
[
{
"resource": "remoteUserService",
"count": 1,
"grade": 1,
"limitApp": "default",
"strategy": 0,
"controlBehavior": 0,
"maxQueueingTimeMs": 2000
}
]
```
Contributor guide
Assessment
This issue has not been assessed yet.