热点key限流(3)
Key 限流 热点
2023-06-13 09:15:03 时间
基本介绍
何为热点 热点即经常访问的数据,很多时候我们希望统计或者限制某个热点数据中访问频次最高的TopN数据,并对其访问进行限流或者其它操作
兜底方法 分为系统默认和客户自定义,两种 之前的case,限流出问题后,都是用sentinel系统默认的提示:Blocked by Sentinel (flow limiting) 我们能不能自定?类似hystrix,某个方法出问题了,就找对应的兜底降级方法? 结论: 从HystrixCommand 到@SentinelResource
@GetMapping("/testHotKey")
@SentinelResource(value = "testHotKey",blockHandler = "dealHandler_testHotKey")
public String testHotKey(@RequestParam(value = "p1",required = false) String p1,
@RequestParam(value = "p2",required = false) String p2){
return "------testHotKey";
}
public String dealHandler_testHotKey(String p1,String p2,BlockException exception)
{
return "-----dealHandler_testHotKey";
}
限流模式只支持QPS模式,固定写死了。(这才叫热点) @SentinelResource注解的方法参数索引,0代表第一个参数,1代表第二个参数,以此类推 单机阀值以及统计窗口时长表示在此窗口时间超过阀值就限流。 上面的抓图就是第一个参数有值的话,1秒的QPS为1,超过就限流,限流后调用dealHandler_testHotKey支持方法。
方法testHotKey里面第一个参数只要QPS超过每秒1次,马上降级处理 访问http://localhost:8401/testHotKey没问题
同理带参数访问也没有问题
同理带参数访问也1s点个俩三次发现问题
参数例外项
上述案例演示了第一个参数p1,当QPS超过1秒1次点击后马上被限流
前提条件 :热点参数的注意点,参数必须是基本类型或者String
相关文章
- django get choice by key
- ORA-22971: invalid datatype for PRIMARY KEY-based object identifier ORACLE 报错 故障修复 远程处理
- ORA-28386: cannot perform a PKI certificate-based Master Key Rekey ORACLE 报错 故障修复 远程处理
- ORA-02432: cannot enable primary key – primary key not defined for table ORACLE 报错 故障修复 远程处理
- ORA-02434: cannot enable unique(string) – unique key not defined for table ORACLE 报错 故障修复 远程处理
- ORA-02455: The number of cluster key column must be 1 ORACLE 报错 故障修复 远程处理
- 获取Redis所有Key的正确方法(获取redis所有key)
- MySQL之Key:别无选择的必经之路(mysql的key)
- Listbox与Listbox with key的区别详解编程语言
- 命令Redis incr Command: A Key Tool for Enhanced Performance(redisincr)
- 时间设置Java中Redis Key的过期时间(redisjava过期)
- 查看Redis中的Key一种有效的数据管理方式(查看Redis的 key)
- 如何一次性清理Redis所有Key值(清除redis的key值)
- 垃圾回收清理Redis部分 Key(清空redis部分key)
- 大象穿针一键导出Redis所有Key(导出redis所有key)
- 借助Redis的Key实现安全的验证(redis验证key)
- Redis集群中热点Key的监控与管理(redis集群热点key)
- Redis缓解热点Key的技术实现(Redis防止热点key)
- Redis实现的防止Key覆盖的方法(redis防止key覆盖)
- Redis中的Key锁机制(redis里key锁)
- Redis迁移指定Key的快速操作(redis迁移指定key)
- Redis精彩呈现全部Key一览无余(redis输出所有key)
- 利用Redis让Key拥有周期性生命(redis设置key周期)
- 的缓存问题使用Redis解决热点Key缓存拥堵问题(redis解决热点key)
- Redis实现指定Key值覆盖(redis覆盖指定key)
- 一步步深入学习Redis如何获取所有Key(redis获得所有key)
- Redis中Key类型的查询与获取(redis获取key类型)