当前位置:网站首页>阿里云微服务(三)Sentinel开源流控熔断降级组件
阿里云微服务(三)Sentinel开源流控熔断降级组件
2022-07-06 09:19:00 【几何学家】
微服务中,稳定性一直是一个避不开的话题,很多时候,会遇到大流量忽然到系统上导致系统扛不住
比如淘宝的双十一促销可能会出现
1.瞬间洪峰超过最大负载
2.激增流量打垮系统
3.热点商品挤占正常流量
4.CPU Load高居不下
服务不可靠的可能原因:
1.RPC超时
2.异常比例升高
3.队列占满
4.线程池占满
微服务中偶尔会出现某个服务挂掉
如果该服务被拖垮导致自己不可用以后又会拖垮其他的服务,进而导致雪崩的情况
所以针对这几种微服务稳定性的场景,流量降级保证稳定性是非常重要的,为了解决这个问题,一般有以下几种措施
1.限流,把QPS限定到某个阈值
2.流量整形,流量是随机的不可预测的,很多时候我们需要把流量调整成想要的形状比如是缓慢增加而不是忽然增加
3.熔断降级,避免被其他服务拖垮
服务中一般分为consumer和provider:
在provider端应该对其进行限流保护,保证其不被激增的流量所打垮,为了保证provider的正常调用,我们可以
1.限流保护,过快的调用直接拒绝
2.授权保护,没授权的应用直接将拒绝
3.系统保护,load超出阈值停止服务
4.热点保护,增强版的限流保护
consumer端为了防止被不稳定的服务调用拖垮,当服务的调用超出了时间阈值或请求量的时候,自动熔断
Hystrix主打的是线程池隔离,优点是隔离的比较彻底,缺点是在服务调用比较多的时候,其会根据每一种服务调用都创建一个线程池,线程池又创建大量的线程,会有上下文切换的危害。ThreadLocal场景下会有问题,比如依赖进行ThreadLocal进行事物或某些标志位的传递
关于Sentinel先启动控制台,控制台启动以后在浏览器中访问sentinel的控制台
配置,接入sentinel

这时候调用接口
在浏览器可以看到调用结果,在控制台可以看到信息
使用控制台对该接口进行限流

可以发现当qps超过设置阈值时,熔断

下面介绍下gateway
相关介绍可以看下这篇帖子:
https://www.cnblogs.com/xuweiweiwoaini/p/13858898.html
在本地项目中配置相关信息
把demo开头的和httpbin开头的流量分别导入道不同的位置上去
调用一下demo接口
可以在foo-service-route中看到,访问几次之后就能在控制台上找到demo-gateway的应用了
在控制台中设置参数限流

边栏推荐
- Exception: ioexception:stream closed
- Halcon knowledge: gray_ Tophat transform and bottom cap transform
- 记录:newInstance()过时的代替方法
- 堆排序【手写小根堆】
- Fairygui gain buff value change display
- [algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix
- isEmpty 和 isBlank 的用法区别
- [GNSS] robust estimation (robust estimation) principle and program implementation
- Liste des boucles de l'interface graphique de défaillance
- Compile GDAL source code with nmake (win10, vs2022)
猜你喜欢

(core focus of software engineering review) Chapter V detailed design exercises
![[算法] 剑指offer2 golang 面试题10:和为k的子数组](/img/63/7422489d09a64ec9f0e79378761bf1.png)
[算法] 剑指offer2 golang 面试题10:和为k的子数组
![Fundamentals of UD decomposition of KF UD decomposition [1]](/img/e9/564e0163c3756c0ba886913f1cfaef.jpg)
Fundamentals of UD decomposition of KF UD decomposition [1]

Fairygui bar subfamily (scroll bar, slider, progress bar)
![[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix](/img/17/e7c9bfa867030af97eb66a7932c7e3.png)
[algorithm] sword finger offer2 golang interview question 13: sum of numbers of two-dimensional submatrix

FairyGUI复选框与进度条的组合使用

Detailed explanation of balanced binary tree is easy to understand

The port is occupied because the service is not shut down normally
![[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积](/img/e0/cea31070d6365eb57013cdead4a175.png)
[算法] 剑指offer2 golang 面试题5:单词长度的最大乘积
![[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和](/img/d5/4bda133498f71ae9fd7a64c6cba8f0.png)
[算法] 剑指offer2 golang 面试题6:排序数组中的两个数字之和
随机推荐
[algorithm] sword finger offer2 golang interview question 1: integer division
Basic DOS commands
【干货】提升RTK模糊度固定率的建议之周跳探测
Record: newinstance() obsolete replacement method
【无标题】
错误: 找不到符号
Halcon knowledge: gray_ Tophat transform and bottom cap transform
Record: I accidentally wrote a recursion next time
Matlab读取GNSS 观测值o文件代码示例
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
[untitled]
isEmpty 和 isBlank 的用法区别
【RTKLIB 2.4.3 b34 】版本更新简介一
Detailed explanation of balanced binary tree is easy to understand
堆排序【手写小根堆】
Comparative analysis of the execution efficiency of MySQL 5.7 statistical table records
Compile GDAL source code with nmake (win10, vs2022)
Wechat applet development experience
VLSM variable length subnet mask partition tips
【GNSS】抗差估计(稳健估计)原理及程序实现