Spring Cloud 核心组件 Sentinel

Spring Cloud 核心组件 Sentinel

  • 作者:DecaMinCow
  • 博客:http://blog.csdn.net/m0_37567301
  • 邮箱:decamincow#gmail.com (#->@)

Sentinel 介绍

Sentinel 是一个面向云原生微服务的流量控制、熔断降级组件
本人推荐用此组件,因为代码侵入低,适合云原生微服务

https://github.com/alibaba/Sentinel/releases

Sentinel 特征

  • 丰富的应用场景:Sentinel 承接了阿里巴巴近 10 年的双十一大促流量的核心场景,例如秒杀(即 突发流量控制在系统容量可以承受的范围)、消息削峰填谷、集群流量控制、实时熔断下游不可用 应用等。
  • 完备的实时监控:Sentinel 同时提供实时的监控功能。您可以在控制台中看到接入应用的单台机器 秒级数据,甚至 500 台以下规模的集群的汇总运行情况。
  • 广泛的开源生态:Sentinel 提供开箱即用的与其它开源框架/库的整合模块,例如与 Spring Cloud、Dubbo的整合。您只需要引入相应的依赖并进行简单的配置即可快速地接入 Sentinel。
  • 完善的 SPI 扩展点:Sentinel 提供简单易用、完善的 SPI 扩展接口。您可以通过实现扩展接口来快 速地定制逻辑。例如定制规则管理、适配动态数据源等。

启动服务

java -jar sentinel-dashboard-1.7.2.jar &

访问 dashboard 后台

# 账号/密码 sentinel/sentinel
http://localhost:8080

相关依赖

<!--SCA -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-alibaba-dependencies</artifactId>
    <version>2.1.0.RELEASE</version>
    <type>pom</type>
    <scope>import</scope>
</dependency>
<dependency>
	<groupId>com.alibaba.cloud</groupId>
   <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- Sentinel支持采用 Nacos 作为规则配置数据源,引入该适配依赖 -->
<dependency>
    <groupId>com.alibaba.csp</groupId>
    <artifactId>sentinel-datasource-nacos</artifactId>
</dependency>

nacos 配置

# 配置限流规则
# DATA ID = {application.name}-flow-rules
# 配置 JSON 格式
 [{
    "resource":"findResumeOpenState",
    "limitApp":"default",
    "grade":1,
    "count":1,
    "strategy":0,
    "controlBehavior":0,
    "clusterMode":false
}]

# 配置降级规则
# DATA ID = {application.name}-degrade-rules
# 配置 JSON 格式
 [{
    "resource":"findResumeOpenState",
    "grade":2,
    "count":1,
    "timeWindow":5
}]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值