一、说明
Sentinel 网关流控支持针对不同的路由和自定义的 API 分组进行流控,支持针对请求属性(如 URL 参数,Client IP,Header 等)进行流控。Sentinel 1.6.3 引入了网关流控控制台的支持,用户可以直接在 Sentinel 控制台上查看 API Gateway 实时的 route 和自定义 API 分组监控,管理网关规则和 API 分组配置。
二、功能接入
1. 网关添加sentinel相关的jar依赖
com.alibaba.cloud
spring-cloud-starter-alibaba-sentinel
com.alibaba.csp
sentinel-datasource-nacos
com.alibaba.cloud
spring-cloud-alibaba-sentinel-gateway
2. 网关zuul的sentinel配置
spring:
# sentinel动态配置规则
cloud:
sentinel:
zuul:
enabled: true
order:
pre: 2000
post: 500
error: -100
filter:
enabled: false
datasource:
# 限流
ds1: