热点参数流控(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 两次之后就流控了
相关推荐
无风听海6 小时前
Python 哨兵值模式(Sentinel Value Pattern)深度解析
开发语言·python·sentinel
空中海1 天前
Redis 原理深度解析:持久化 × 主从复制 × Sentinel × Cluster × 性能排查全攻略
数据库·redis·sentinel
梵得儿SHI2 天前
SpringCloud 生产级落地:Docker 容器化 + K8s 编排部署全攻略(含完整 yaml + 避坑指南)
docker·云原生·kubernetes·k8s·springcloud·微服务部署·java 后端
接着奏乐接着舞3 天前
Sentinel
sentinel
随风,奔跑3 天前
Spring Boot Alibaba(三)----Sentinel
spring boot·后端·sentinel
甜鲸鱼3 天前
JWT过滤器:从单体应用到微服务架构
微服务·架构·gateway·springcloud
notfound40433 天前
解决SpringCloudGateway用户请求超时导致日志未记录情况
java·spring boot·spring·gateway·springcloud
武超杰3 天前
Sentinel 安装启动 + 全规则详解 + Feign 整合 + 持久化
sentinel
青槿吖3 天前
Sentinel 进阶实战:Feign 整合 + 全局异常 + Nacos 持久化,生产环境直接用
java·开发语言·spring cloud·微服务·云原生·ribbon·sentinel
StackNoOverflow3 天前
Sentinel服务保护框架完全指南:从原理到实践
java·数据库·sentinel