SpringCloud Alibaba Sentinel实现熔断与限流

SpringCloud Alibaba Sentinel

1、Sentinel是什么?

1.1、前言说明:

作用:实现熔断与限流 Hystrix断路器 升级版

文档直达: 官网中文文档

image-20200825221855431

1.2、Sentinel 的主要特性

image-20200825222003319

2、Sentinel下载安装运行

下载地址: https://github.com/alibaba/Sentinel/releases

image-20200825222801317

直接 java -jar sentinel-dashboard-1.7.2.jar 运行
http://localhost:8080 账号:sentinel sentinel

image-20200825224231843

3、创建演示工程

image-20200825230415272

application.yml

server:
  port: 8401

spring:
  application:
    name: cloudalibaba-sentinel-service
  cloud:
    nacos:
      discovery:
        server-addr: 192.168.199.130:8848 # nacos服务注册中心
    sentinel:
      transport:
        dashboard: localhost:8080
        port: 8719  #默认8719,假如被占用了会自动从8719开始依次+1扫描。直至找到未被占用的端口

# 监控图形化 界面
management:
  endpoints:
    web:
      exposure:
        include: '*'

注意:sentinel是懒加载机制 ,先执行几次接口 ,然后进入控制台查看流控详情

image-20200825230055826

4、Sentinel流控

4.1、基本介绍

image-20200825232704497

详细说明:

image-20200825232759057

image-20200825232828443

4.2、流控模式

① 直接(默认)

image-20200825232704497

当1s内多次访问 /testA 时 提示如下(阈值:QPS):

image-20200825233132415

如果 (阈值:线程数)则意味着当1s内多个线程访问该API会被流控

小插曲:直接调用默认报错信息,技术方面OK but,是否应该有我们自己的后续处理?(可以)

类似有一个fallback的兜底方法?

② 关联

image-20200825235906635

③ 链路

4.3、流控效果

② 关联

[外链图片转存中…(img-8KMZGlWX-1611066680980)]

③ 链路

4.3、流控效果

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值