当前位置:网站首页>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时,阈值将按照我们指定的特例进行计算。
边栏推荐
- SetoolKit User Guide
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
- 多智能体协同控制研究中光学动作捕捉与UWB定位技术比较
- AI cocoa AI frontier introduction (7.31)
- MySQL【子查询】
- 4.爬虫之Scrapy框架2数据解析&配置参数&数据持久化&提高Scrapy效率
- Tortoise speed by "template"
- Motion capture system for end-positioning control of flexible manipulators
- Open Inventor 10.12 重大改进--和谐版
- C#高级--委托
猜你喜欢
The recently popular domestic interface artifact Apipost experience
An article makes it clear!What is the difference and connection between database and data warehouse?
动作捕捉系统用于柔性机械臂的末端定位控制
多智能体协同控制研究中光学动作捕捉与UWB定位技术比较
A detailed explanation of the usage of Async and Await in C#
Nuget打包并上传教程
Resnet&API
The pre-sale of the new Hyundai Paristi is open, and safety and comfort are not lost
OAuth2:微服务权限校验Session共享
什么是消息队列呢?
随机推荐
Uniapp WeChat small application reference standard components
尚硅谷-JVM-内存和垃圾回收篇(P1~P203)
OAuth2:四种授权方式
Save and load numpy matrices and vectors, and use the saved vectors for similarity calculation
【redis】发布和订阅消息
1-hour live broadcast recruitment order: industry leaders share dry goods, and enterprise registration is open丨qubit · point of view
Selenium自动化测试之Selenium IDE
CodeIgniter 打开错误日志
Redis与分布式:主从复制
OAuth2:搭建授权服务器
LeetCode·每日一题·1161.最大层内元素和·层次遍历
hyperf的启动源码分析(二)——请求如何到达控制器
DELL SC compellent 康贝存储系统怎么抓取配置信息
The pre-sale of the new Hyundai Paristi is open, and safety and comfort are not lost
使用NVM进行node版本切换管理
OAuth2:单点登陆客户端
Four ways to clear the float and its principle understanding
4.爬虫之Scrapy框架2数据解析&配置参数&数据持久化&提高Scrapy效率
49.【拷贝构造函数与重载】
【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解