热点参数流控(Sentinel)

热点参数流控

  • 热点流控 资源必须使用注解 @SentinelResource

编写接口 以及 热点参数流控处理器

java 复制代码
/**
 * 热点流控 必须使用注解 @SentinelResource
 * @param id
 * @return
 */
@RequestMapping("/getById/{id}")
@SentinelResource(value = "getById", blockHandler = "hotParamHandler")
public Object getById(@PathVariable("id") Integer id) {
    return "hi, order " + id;
}

/** 
 * 热点参数流控处理器 
 * 
 * @param id 
 * @param be 
 * @return 
 */
public Object hotParamHandler(@PathVariable("id") Integer id, BlockException be){
    return id + " -> 热点流控了";
}

设置热点规则

  • 热点流控规则 是针对 QPS 进行流控的

设置入口

设置热点规则

  • 设置第几个参数,从0开始 以及 QPS的流控阈值 普通值阈值为10

设置参数

  • 编辑热点流控规则 -> 高级选项; 设置参数 id=2 的 流控阈值为2

访问效果

  • 其他参数 10 次 之后才进行流控, id=2 两次之后就流控了
相关推荐
hzzzzzo06 小时前
微服务保护全攻略:从雪崩到 Sentinel 实战
数据库·微服务·sentinel
没有bug.的程序员1 天前
Redis Sentinel:高可用架构的守护者
java·redis·架构·sentinel
波波烤鸭1 天前
Sentinel 原理与源码解析:流控、熔断、降级到热点限流的一体化方案
sentinel
曾经的三心草2 天前
springcloud二-Sentinel
spring·spring cloud·sentinel
iiYcyk5 天前
Eureka与Nacos的区别-服务注册+配置管理
springcloud
T_Ghost5 天前
SpringCloud微服务服务容错机制Sentinel熔断器
spring cloud·微服务·sentinel
你是人间五月天6 天前
sentinel实现控制台与nacos数据双向绑定
windows·sentinel
无名客06 天前
sentinel限流常见的几种算法以及优缺点
算法·sentinel·限流
tsxchen6 天前
centos9安装sentinel
sentinel
寒士obj6 天前
Sentinel服务治理:服务降级、熔断与线程隔离
sentinel