热点参数流控(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 两次之后就流控了
相关推荐
xiaoxiangsiyan1 天前
LNMP + Redis Sentinel 高可用架构部署手册(续)
运维·网络·数据库·redis·缓存·架构·sentinel
敲代码的嘎仔2 天前
从零搭建微服务:Spring Cloud Alibaba 全家桶踩坑实录(Nacos + OpenFeign + Gateway + Sentinel)
java·spring boot·spring·spring cloud·微服务·gateway·sentinel
欢醉3 天前
线上惊魂:Nacos 抖动导致大面积服务掉线,我们是怎么兜底的
nacos·springcloud
小罗水4 天前
第14章 Sentinel 限流与 AI 降级
人工智能·sentinel
he___H4 天前
Sentinel使用实操
java·开发语言·sentinel
随风M记忆s5 天前
GEE&Python-demo:利用Sentinel-监测北京奥林匹克森林公园年NDVI变化(附Python版)
开发语言·python·sentinel
X-⃢_⃢-X5 天前
六、Sentinel
网络·数据库·sentinel
YOU OU7 天前
Redis哨兵 & 集群
数据库·redis·sentinel
爱学习的小可爱卢7 天前
SpringCloud——SkyWalking全链路监控源码深度解析
java·微服务·springcloud·skywalking
爱学习的小可爱卢7 天前
SpringCloud——SkyWalking告警规则触发WebHook全解析
java·微服务·springcloud·skywalking