SpringCloud Alibaba Sentinel
1、Sentinel是什么?
1.1、前言说明:
作用:实现熔断与限流 (Hystrix断路器 升级版)
文档直达: 官网中文文档
1.2、Sentinel 的主要特性
2、Sentinel下载安装运行
下载地址: https://github.com/alibaba/Sentinel/releases
直接 java -jar sentinel-dashboard-1.7.2.jar 运行
http://localhost:8080
账号:sentinel sentinel
3、创建演示工程
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是懒加载机制 ,先执行几次接口 ,然后进入控制台查看流控详情
4、Sentinel流控
4.1、基本介绍
详细说明:
4.2、流控模式
① 直接(默认)
当1s内多次访问 /testA 时 提示如下(阈值:QPS):
如果 (阈值:线程数)则意味着当1s内多个线程访问该API会被流控
小插曲:直接调用默认报错信息,技术方面OK but,是否应该有我们自己的后续处理?(可以)
类似有一个fallback的兜底方法?
② 关联
③ 链路
4.3、流控效果
② 关联
[外链图片转存中…(img-8KMZGlWX-1611066680980)]