热点参数流控(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 两次之后就流控了
相关推荐
sniper_fandc9 小时前
Spring Cloud系列—Alibaba Sentinel授权与规则管理及推送
spring cloud·sentinel
xiao-xiang1 天前
redis-sentinel基础概念及部署
数据库·redis·sentinel
Armyyyyy丶8 天前
Sentinel原理之责任链详解
java·sentinel·熔断限流
超人也会哭️呀9 天前
Redis(八):Redis高并发高可用(哨兵Sentinel)
redis·bootstrap·sentinel·哨兵·哨兵模式·高并发高可用
毛小茛12 天前
Spring Cloud Gateway 实现登录校验:构建统一认证入口
springcloud
转身後 默落12 天前
14.Redis 哨兵 Sentinel
redis·bootstrap·sentinel
●VON15 天前
重生之我在暑假学习微服务第七天《微服务之服务治理篇》
java·学习·微服务·云原生·nacos·架构·springcloud
CHARLIIE16 天前
sentinel
sentinel
Rancemy17 天前
springcloud03-Nacos配置中心
java·intellij-idea·springcloud
曹朋羽18 天前
spring cloud sentinel 动态规则配置
spring·spring cloud·sentinel