热点参数流控(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 两次之后就流控了
相关推荐
多敲代码防脱发2 天前
Alibaba Sentinel(熔断、限流)(国内下载Sentinel)
java·开发语言·sentinel
2601_962181964 天前
【Spring Cloud Alibaba】Sentinel 服务熔断与流量控制
sentinel
lv__pf6 天前
Sentinel【TL微服务10、11】
java·微服务·sentinel
凤山老林7 天前
高可靠 API 网关架构:Spring Cloud Gateway 集成 Sentinel 实现智能限流、动态路由与安全管控
安全·spring cloud·架构·sentinel
jonyleek7 天前
技术实践:基于 Vue3 + Spring Cloud 微服务实现私有化文档系统的类 SaaS 协同体验
微服务·私有化部署·vue3·springcloud·协同编辑·jvs企业文档·无忧企业文档
就叫_这个吧8 天前
java springcloud熔断降级组件sentinel基础应用及nacos持久化处理
java·spring cloud·nacos·sentinel
aikopen9 天前
高可用 API 网关限流与微服务过载保护实战:从 Sentinel 动态阈值到 DB 连接池舱壁
数据库·微服务·sentinel
欢醉10 天前
干货分享Gateway踩坑实录:Netty直接内存把网关吃垮了OutOfDirectMemoryError
jvm·springcloud
ruleslol11 天前
Sentinel限流
sentinel
肠畔码农12 天前
高可用底座:Redis 哨兵机制(Sentinel)底层内核拆解
redis·bootstrap·sentinel