当前位置:网站首页>【微服务|Sentinel】sentinel数据持久化
【微服务|Sentinel】sentinel数据持久化
2022-06-27 20:50:00 【步尔斯特】
持久化流程
为什么持久化?不持久化,重启应用,数据就没了啊。这也就是所谓的原始模式。
我们推荐通过控制台设置规则后将规则推送到统一的规则中心,客户端实现 ReadableDataSource 接口端监听规则中心实时获取变更。
流程如下:
DataSource 扩展常见的实现方式
- 拉模式:客户端主动向某个规则管理中心定期轮询拉取规则,这个规则中心可以是 RDBMS、文件,甚至是 VCS 等。这样做的方式是简单,缺点是无法及时获取变更;
- 推模式:规则中心统一推送,客户端通过注册监听器的方式时刻监听变化,比如使用 Nacos、Zookeeper 等配置中心。这种方式有更好的实时性和一致性保证。
我们来看看都有哪几种模式以及他们之间的区别。
pom文件依赖
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
yaml配置
spring:
cloud:
sentinel:
transport:
dashboard: localhost:8080
# port: 8719
# client-ip: localhost
eager: true
web-context-unify: false
datasource:
# 规则命名:可以任意命名
flow-rule:
# 持久化在nacos中,还可选择zookeeper,consul等
nacos:
# nacos服务地址
server-addr: ip:8848
namespace: 45de6484-833e-4cce-b895-f14095f20605
group-id: SENTINEL_GROUP
# 配置DataId
data-id: ossa-service-producer-flow-rule
data-type: json
# 流控规则:FLOW,DEGRADE,PARAM_FLOW等
rule-type: flow
nacos配置
[
{
"resource": "/test",
"limitApp": "default",
"grade": 1,
"count": 2,
"strategy": 0,
"controlBehavior": 0,
"clusterMode": false
},
{
"resource": "/producer/{id}",
"limitApp": "default",
"grade": 1,
"count": 2,
"strategy": 0,
"controlBehavior": 0,
"clusterMode": false
}
]
边栏推荐
- 量化交易入门教程
- MySQL删除表后如何使ID从1开始
- Practice torch FX: pytorch based model optimization quantization artifact
- 用pytorch进行CIFAR-10数据集分类
- Follow the archiving tutorial to learn rnaseq analysis (III): count standardization using deseq2
- To build a "strong core" in Nansha, the first IC Nansha conference was held in Nansha
- Mysql database experiment report (I)
- This year's examinees are more "desperate" than the college entrance examination
- webService
- The most illusory richest man in China is even more illusory
猜你喜欢
Spark BUG實踐(包含的BUG:ClassCastException;ConnectException;NoClassDefFoundError;RuntimeExceptio等。。。。)
This year's examinees are more "desperate" than the college entrance examination
This kind of people began to be robbed by VC with a monthly salary of 80000 yuan
webService
STM32与RC522简单公交卡系统的设计
雪糕还是雪“高”?
居家办公竟比去公司上班还累?
Online JSON to plaintext tool
To build a "strong core" in Nansha, the first IC Nansha conference was held in Nansha
Design of STM32 and rc522 simple bus card system
随机推荐
Avoid using 100vh[easy to understand] at mobile terminal
go日志包 log的使用
向量召回和字面召回的选择与权衡
广告太「野」,吉野家「渡劫」
Feign通过自定义注解实现路径的转义
Classification of cifar-10 dataset with pytorch
使用同花顺手机炒股安全吗?
fiddler 监听不到接口怎么办
Spark bug practice (including bug:classcastexception; connectexception; NoClassDefFoundError; runtimeException, etc.)
clickonce 部署ClickOnce应用程序时出错-清单中的引用与下载的程序集的标识不匹配
Design of STM32 and rc522 simple bus card system
Open source of local run / development library of hiplot online drawing tool
[随笔]ME53N 增加按钮,调用URL
Realization of kaggle cat dog recognition by pytorch
陈云pytorch学习笔记_用50行代码搭建ResNet
MySQL删除表后如何使ID从1开始
[js]var, let,const 的区别
ABAP essay - material master data interface enhancement - tab enhancement
pytorch基础(1)
To build a "strong core" in Nansha, the first IC Nansha conference was held in Nansha