热点参数流控(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 两次之后就流控了
相关推荐
Owen__z2 天前
GEE统计特定区域特定时间上的Landsat/Sentinel的影像信息
python·sentinel·gee·geemap·landsat
我要去腾讯2 天前
Springcloud核心组件之Sentinel详解
java·spring cloud·sentinel
装不满的克莱因瓶3 天前
【Java架构师】各个微服务之间有哪些调用方式?
java·开发语言·微服务·架构·dubbo·restful·springcloud
众俗4 天前
SpringCloudAlibaba整合开发
springcloud·alibaba
哦你看看7 天前
Redis Sentinel哨兵集群
linux·redis·bootstrap·sentinel
2501_938790078 天前
Spring Cloud Alibaba 2023 版:Nacos 服务发现与 Sentinel 限流的整合方案
sentinel·服务发现
青鱼入云8 天前
Sentinel介绍
微服务·sentinel
青鱼入云8 天前
Feign如何集成Sentinel
spring cloud·微服务·sentinel
一周困⁸天.10 天前
Redis Sentinel哨兵集群
redis·bootstrap·sentinel
一条懒鱼66611 天前
Redis Sentinel哨兵集群
数据库·redis·sentinel