热点参数流控(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 两次之后就流控了
相关推荐
机灵猫12 分钟前
守卫系统的最后一道防线:深入 Sentinel 限流降级与熔断机制(对比 Hystrix)
java·hystrix·sentinel
weixin_4397062518 分钟前
spring boot+nacos+gateway+sentinel的简单例子
spring boot·gateway·sentinel
墨白曦煜2 天前
微服务容错设计:Sentinel 全局异常处理与 Feign 降级策略的边界权衡
微服务·架构·sentinel
没有bug.的程序员2 天前
Spring Cloud Gateway 架构与执行流程:从原理到性能优化的深度探索
微服务·云原生·eureka·性能优化·架构·sentinel·服务发现
杜子不疼.2 天前
Spring Cloud 微服务实战:Nacos+Sentinel+Gateway 核心组件详解
spring cloud·微服务·sentinel
enjoy编程4 天前
Spring Boot 4 如何使用Sentinel进行限流-II【基于Sentinel Spring MVC Adapter实现】
spring boot·spring·sentinel·服务限流·webmvc·servlet 6.x
没有bug.的程序员4 天前
Sentinel 流控原理深度解析:构建高可用微服务的底层架构
java·算法·微服务·云原生·架构·sentinel·负载均衡
代码的奴隶(艾伦·耶格尔)5 天前
Sentinel限流熔断
java·前端·sentinel
东东的脑洞5 天前
【面试突击】Redis 哨兵(Sentinel)完全指南:从原理到实战
redis·面试·sentinel
enjoy编程5 天前
Spring Boot 4 如何使用Sentinel进行限流?
spring boot·sentinel·限流·熔断降级·流量控制·服务限流·系统负载保护