热点参数流控(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 两次之后就流控了
相关推荐
zfj3218 小时前
手动搭建Redis1主2从+ 3 Sentinel 高可用集群
redis·sentinel·高可用
power-辰南5 天前
基于 Spring Cloud + Sentinel 的全面流量治理方案
spring·spring cloud·sentinel·流量治理
蔚一5 天前
微服务SpringCloudAlibaba组件sentinel教程【详解sentinel的使用以及流量控制、熔断降级、热点参数限流等,附有示例+代码】
java·spring boot·后端·微服务·架构·sentinel·intellij-idea
华农第一蒟蒻6 天前
Sentinel
java·开发语言·sentinel
qw9496 天前
Redis 09章——哨兵(sentinel)
数据库·redis·sentinel
azoon.top6 天前
springcloud集成gateway
微服务·gateway·springcloud
FG.7 天前
微服务保护---Sentinel
微服务·sentinel
Xwzzz_7 天前
SpringCloud中Sentinel基础场景和异常处理
java·spring cloud·sentinel
bing_1587 天前
Springboot 中如何使用Sentinel
spring boot·sentinel
power-辰南9 天前
微服务限流策略与性能优化全解析
性能优化·sentinel·springcloud·流量监控·流量治理