1. springboot-lll-starter限流说明
功能添加,项目地址
1.1. 配置
限流在order
模块的bootstrap.yml
配置中,主要为如下配置
spring:
cloud:
sentinel:
eager: false
transport:
dashboard: localhost:8080
datasource:
ds:
nacos:
server-addr: localhost:8848
dataId: ${spring.application.name}-sentinel
ruleType: flow
groupId: DEFAULT_GROUP
# ds1:
# file:
# file: classpath:flowrule.json
# rule-type: flow
# data-type: json
写了两种方式,读文件和读nacos配置
- 要想实现修改控制配置持久化,还需要修改sentinal控制台代码,参考
http://www.imooc.com/article/details/id/289464
1.2. json
限流配置文件内容
[
{
"resource":"user_list",
"limitApp":"default",
"grade":1,
"count":1,
"strategy":0,
"controlBehavior":0,
"clusterMode":"false"
}
]
- resource:资源名称;
- limitApp:来源应用(默认)
- grade:阈值类型;0:线程数;1:表示QPS
- strategy:流控模式,0:直接;1:关联;2:链路
- controlBehavior:流控的结果;0:快速失败;1:Warm up;2:排队等待
- clusterMode:是否集群
1.3. 效果
来源:oschina
链接:https://my.oschina.net/u/4255948/blog/4277116