springboot-lll-starter限流说明

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. 效果

springboot-lll-starter限流说明_第1张图片

GitHub地址:https://github.com/tzxylao/spring-boot-lll-starter

你可能感兴趣的:(springboot-lll-starter限流说明)