热点参数流控(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 两次之后就流控了
相关推荐
@HNUSTer2 天前
基于 GEE 平台用 Sentinel-1 SAR 数据实现山区潜在滑坡检测
云计算·sentinel·数据集·遥感大数据·gee·云平台·sar
还是鼠鼠5 天前
《黑马商城》微服务保护-详细介绍【简单易懂注释版】
java·spring boot·spring·spring cloud·sentinel·maven
森林-8 天前
Spring Cloud Netflix Eureka:从微服务基础到高可用集群实战
微服务·云原生·eureka·springcloud
月夕·花晨8 天前
Gateway-过滤器
java·分布式·spring·spring cloud·微服务·gateway·sentinel
非凡ghost10 天前
Hard Disk Sentinel(固态硬盘监控) 多语便携版
windows·sentinel·软件需求
ccccczy_12 天前
SpringCloudGateway:像城市交通指挥系统一样的微服务网关
java·springcloud·微服务网关·api网关·springcloudgateway
柳贯一(逆流河版)12 天前
Sentinel 深度解析:限流与熔断降级的微服务稳定性保障实践
微服务·架构·sentinel
耳东哇13 天前
sentinel docker gateway k8s 集群 主从
docker·gateway·sentinel
遥感之家14 天前
AWS下载sentinel-2原始影像
云计算·sentinel·aws