Spring Cloud Alibaba之 Sentinel( 四 )
默认情况下 , xml 格式是不支持的 。 需要添加 jackson-dataformat-xml 依赖后才会自动生效 。
关于 Sentinel 动态数据源的实现原理 , 参考: 动态规则扩展
Zuul 支持参考 Sentinel 网关限流
若想跟 Sentinel Starter 配合使用 , 需要加上 spring-cloud-alibaba-sentinel-gateway 依赖 , 同时需要添加 spring-cloud-starter-netflix-zuul 依赖来让 spring-cloud-alibaba-sentinel-gateway 模块里的 Zuul 自动化配置类生效:
Spring Cloud Gateway 支持参考 Sentinel 网关限流
若想跟 Sentinel Starter 配合使用 , 需要加上 spring-cloud-alibaba-sentinel-gateway 依赖 , 同时需要添加 spring-cloud-starter-gateway 依赖来让 spring-cloud-alibaba-sentinel-gateway 模块里的 Spring Cloud Gateway 自动化配置类生效:
Sentinel 对外暴露的 EndpointSentinel 内部提供了一个 Endpoint, 对应的 endpoint id 为 sentinel 。
Endpoint 暴露的 json 中包含了多种属性:
- appName: 应用名
- logDir: 日志所在目录
- logUsePid: 日志文件名是否带上进程id
- blockPage: 限流 block 之后跳转的页面
- metricsFileSize: metrics 文件的大小
- metricsFileCharset: metrics 文件对应的字符集
- totalMetricsFileCount: metrics 最多保留的文件数
- consoleServer: sentinel dashboard 地址
- clientIp: 客户端 ip
- heartbeatIntervalMs: 客户端跟 dashboard 的心跳间隔时间
- clientPort: 客户端需要暴露的端口跟 dashboard 进行交互
- coldFactor: 冷启动因子
- filter: CommonFilter 相关的属性 ,比如 order, urlPatterns 以及 enable
- datasource: 客户端配置的数据源信息
- rules: 客户端生效的规则 , 内部含有 flowRules, degradeRules, systemRules, authorityRule, paramFlowRule
【Spring Cloud Alibaba之 Sentinel】
{ "blockPage": null, "appName": "sentinel-example", "consoleServer": "localhost:8080", "coldFactor": "3", "rules": {"flowRules": [{"resource": "GET:","limitApp": "default","grade": 1,"count": 0.0,"strategy": 0,"refResource": null,"controlBehavior": 0,"warmUpPeriodSec": 10,"maxQueueingTimeMs": 500,"clusterMode": false,"clusterConfig": null}, {"resource": "/test","limitApp": "default","grade": 1,"count": 0.0,"strategy": 0,"refResource": null,"controlBehavior": 0,"warmUpPeriodSec": 10,"maxQueueingTimeMs": 500,"clusterMode": false,"clusterConfig": null}, {"resource": "/hello","limitApp": "default","grade": 1,"count": 1.0,"strategy": 0,"refResource": null,"controlBehavior": 0,"warmUpPeriodSec": 10,"maxQueueingTimeMs": 500,"clusterMode": false,"clusterConfig": null}] }, "metricsFileCharset": "UTF-8", "filter": {"order": -2147483648,"urlPatterns": ["/*"],"enabled": true }, "totalMetricsFileCount": 6, "datasource": {"ds1": {"file": {"dataType": "json","ruleType": "FLOW","converterClass": null,"file": "...","charset": "utf-8","recommendRefreshMs": 3000,"bufSize": 1048576},"nacos": null,"zk": null,"apollo": null,"redis": null} }, "clientIp": "30.5.121.91", "clientPort": "8719", "logUsePid": false, "metricsFileSize": 52428800, "logDir": "...", "heartbeatIntervalMs": 10000}
- Cloud PC服务曝光:将Windows 10桌面挪到云端
- 基于Spring+Angular9+MySQL开发平台
- 苹果终于修复 iCloud 登录激活问题
- 苹果:影响新设备设置的“iCloud账号与登录”故障已解决
- 百度|百度CTO王海峰:智能云AI cloud活跃客户数增长65%
- 别不拿GateWay当回事,SpringCloud告诉你错了
- 华为云Cloud for Good温暖上海,原来上海的智慧是这样的
- web 安全之 Spring Security 入门教程
- Spring Application实例化流程和构造方法参数
- 百度CTO王海峰:AI Cloud活跃客户增65%,昆仑1芯片量产约两万片