Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么对整个OpenFeign的客户端接口进行QPS总量限流 #3471

Open
xiaopang-8 opened this issue Nov 6, 2024 · 0 comments
Open

怎么对整个OpenFeign的客户端接口进行QPS总量限流 #3471

xiaopang-8 opened this issue Nov 6, 2024 · 0 comments

Comments

@xiaopang-8
Copy link

现在有这样一个需求, 我在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
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant