当前位置:网站首页>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时,阈值将按照我们指定的特例进行计算。
边栏推荐
- LeetCode旋转数组
- Samba 远程命令执行漏洞(CVE-2017-7494)
- 我把问烂了的MySQL面试题总结了一下
- Resnet&API
- Reasons and solutions for Invalid bound statement (not found)
- 【Pytorch】F.softmax()方法说明
- Linux bash: redis-server: command not found
- 已解决(pymysqL连接数据库报错)pymysqL.err.ProgrammingError: (1146,“Table ‘test.students‘ doesn‘t exist“)
- Nuget package and upload tutorial
- LeetCode·每日一题·1161.最大层内元素和·层次遍历
猜你喜欢
随机推荐
Node version switching management using NVM
CLion用于STM32开发
Numbers that appear only once in LeetCode
[QNX Hypervisor 2.2用户手册]9.13 rom
The JVM a class loader
IDEA connects to MySQL database and uses data
技能大赛训练题:MS15_034漏洞验证与安全加固
LeetCode·每日一题·1161.最大层内元素和·层次遍历
BigDecimal 简介,常用方法
20.nn.Module
MySQL [subquery]
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
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
Redis与分布式:主从复制
csdn发文助手问题
mysql8, starttime的下一个值作为endtime的上一个值?
C语言基础练(九九乘法表)与打印不同星号图案
232层3D闪存芯片来了:单片容量2TB,传输速度提高50%
The recently popular domestic interface artifact Apipost experience









