当前位置:网站首页>Sentinel热点参数限流
Sentinel热点参数限流
2022-07-31 14:05:00 【Leon_Jinhai_Sun】
我们还可以对某一热点数据进行精准限流,比如在某一时刻,不同参数被携带访问的频率是不一样的:
由于携带参数a的请求比较多,我们就可以只对携带参数a的请求进行限流。
这里我们创建一个新的测试请求映射:
@RequestMapping("/test")
@SentinelResource("test") //注意这里需要添加@SentinelResource才可以,用户资源名称就使用这里定义的资源名称
String findUserBorrows2(@RequestParam(value = "a", required = false) int a,
@RequestParam(value = "b", required = false) int b,
@RequestParam(value = "c",required = false) int c) {
return "请求成功!a = "+a+", b = "+b+", c = "+c;
}启动之后,我们在Sentinel里面进行热点配置:

然后开始访问我们的测试接口,可以看到在携带参数a时,当访问频率超过设定值,就会直接被限流,这里是直接在后台抛出异常:


而我们使用其他参数或是不带a参数,那么就不会出现这种问题了:

除了直接对某个参数精准限流外,我们还可以对参数携带的指定值单独设定阈值,比如我们现在不仅希望对参数a限流,而且还希望当参数a的值为10时,QPS达到5再进行限流,那么就可以设定例外:

这样,当请求携带参数a,且参数a的值为10时,阈值将按照我们指定的特例进行计算。
边栏推荐
- All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
- I summed up the bad MySQL interview questions
- 线程池的使用二
- 技能大赛dhcp服务训练题
- MySQL【聚合函数】
- 五个维度着手MySQL的优化
- Controller层代码这么写,简洁又优雅!
- “听我说谢谢你”还能用古诗来说?清华搞了个“据意查句”神器,一键搜索你想要的名言警句...
- [QNX Hypervisor 2.2 User Manual] 9.13 rom
- 232层3D闪存芯片来了:单片容量2TB,传输速度提高50%
猜你喜欢
随机推荐
Unity study notes Description of AVPro video jump function (Seeking)
OAuth2:微服务权限校验Session共享
技能大赛训练题:登录安全加固
Shell脚本经典案例:文件的备份
MySQL [aggregate function]
页面整屏滚动效果
endnote引用
OAuth2:资源服务器
CLion用于STM32开发
4.爬虫之Scrapy框架2数据解析&配置参数&数据持久化&提高Scrapy效率
1小时直播招募令:行业大咖干货分享,企业报名开启丨量子位·视点
An article makes it clear!What is the difference and connection between database and data warehouse?
为什么 wireguard-go 高尚而 boringtun 孬种
ML、DL、CV常见的问题整理
Redis 】 【 publish and subscribe message
Analysis of the startup source code of hyperf (2) - how the request reaches the controller
The 232-layer 3D flash memory chip is here: the single-chip capacity is 2TB, and the transmission speed is increased by 50%
C# using ComboBox control
C# control StatusStrip use
In the future, the interviewer asks you why it is not recommended to use Select *, please answer him out loud!


![MySQL [subquery]](/img/0b/9bbf54c500d85976e6d6776b6c6f13.png)






