热点参数流控(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 两次之后就流控了
相关推荐
云技纵横13 小时前
本地限流与 Redis 分布式限流的无缝切换 技术栈:Sentinel 线程池隔离 + Nginx + Kafka
redis·分布式·sentinel
墨白曦煜2 天前
Redis 故障检测进化论:从 Sentinel 到 Cluster 的机制演变
数据库·redis·sentinel
全靠bug跑3 天前
Sentinel 服务保护实战:限流、隔离与熔断降级详解
java·sentinel
kkoral5 天前
单机docker部署的redis sentinel,使用python调用redis,报错
redis·python·docker·sentinel
墨白曦煜5 天前
深入剖析 Redis 客户端:Sentinel 模式下的“寻址”与“感知”艺术
数据库·redis·sentinel
遇见火星5 天前
Redis高可用-哨兵模式(Sentinel)
redis·sentinel
YDS8297 天前
SpringCloud —— Sentinel详解
java·spring cloud·sentinel
后端小张7 天前
【JAVA 进阶】深入理解Sentinel:分布式系统的流量守卫者
java·开发语言·spring boot·后端·spring·spring cloud·sentinel
小马爱打代码7 天前
面试题:Hystrix与Sentinel区别
hystrix·sentinel
破烂pan8 天前
Python 整合 Redis 哨兵(Sentinel)与集群(Cluster)实战指南
redis·python·sentinel