热点参数流控(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 两次之后就流控了
相关推荐
默默coding的程序猿3 小时前
3.前端和后端参数不一致,后端接不到数据的解决方案
java·前端·spring·ssm·springboot·idea·springcloud
sevevty-seven11 天前
Sentinel
linux·服务器·sentinel
秋恬意11 天前
什么是Sentinel?以及优缺点
sentinel
liang899911 天前
Sentinel(一):Sentinel 介绍和安装
sentinel
武子康12 天前
Java-51 深入浅出 Tomcat 手写 Tomcat 类加载机制 双亲委派机制 生命周期 插件化
java·开发语言·spring boot·后端·spring·tomcat·springcloud
述雾学java12 天前
Sentinel 服务限流机制
sentinel
2401_8532757313 天前
Sentinel实现原理
服务器·网络·sentinel
苏格拉没有底_coder15 天前
【Redis】Sentinel哨兵
redis·sentinel
苏格拉没有底_coder20 天前
基于 Spring Cloud Gateway + Sentinel 实现高并发限流保护机制
sentinel
未来并未来22 天前
Sentinel 流量控制安装与使用
开发语言·python·sentinel