当前位置:网站首页>阿里云微服务(三)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的应用了
在控制台中设置参数限流

边栏推荐
- [算法] 劍指offer2 golang 面試題2:二進制加法
- 错误: 找不到符号
- [GNSS] robust estimation (robust estimation) principle and program implementation
- FGUI工程打包发布&导入Unity&将UI显示出来的方式
- 【无标题】
- FairyGUI增益BUFF数值改变的显示
- GPS高程拟合抗差中误差的求取代码实现
- 平衡二叉树详解 通俗易懂
- How to reduce the shutdown time of InnoDB database?
- Special palindromes of daily practice of Blue Bridge Cup
猜你喜欢
![[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire](/img/c2/6f6c3bd4d70252ba73addad6a3a9c1.png)
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire

Detailed explanation of balanced binary tree is easy to understand
![[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once](/img/f7/23ffc81ec8e9161c15d863c1a67916.png)
[algorithm] sword finger offer2 golang interview question 4: numbers that appear only once

Problems and solutions of robust estimation in rtklib single point location spp
![[算法] 剑指offer2 golang 面试题4:只出现一次的数字](/img/f7/23ffc81ec8e9161c15d863c1a67916.png)
[算法] 剑指offer2 golang 面试题4:只出现一次的数字

On March 15, the official version of go 1.18 was released to learn about the latest features and usage
![[algorithm] sword finger offer2 golang interview question 10: subarray with sum K](/img/63/7422489d09a64ec9f0e79378761bf1.png)
[algorithm] sword finger offer2 golang interview question 10: subarray with sum K
![[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity](/img/9d/7284c1399964d3fb48886f12e4941c.jpg)
[dry goods] cycle slip detection of suggestions to improve the fixed rate of RTK ambiguity

Rt-ppp test using rtknavi

RTKLIB: demo5 b34f.1 vs b33
随机推荐
FairyGUI按钮动效的混用
[algorithm] sword finger offer2 golang interview question 2: binary addition
Fundamentals of UD decomposition of KF UD decomposition [1]
Detailed explanation of balanced binary tree is easy to understand
Novatel board oem617d configuration step record
[算法] 剑指offer2 golang 面试题4:只出现一次的数字
FairyGUI循环列表
[algorithme] swordfinger offer2 golang question d'entrevue 2: addition binaire
闇の連鎖(LCA+树上差分)
isEmpty 和 isBlank 的用法区别
Code example of MATLAB reading GNSS observation value o file
What are the advantages of using SQL in Excel VBA
记录:动态Web项目servlet访问数据库404错误之解决
GNSS positioning accuracy index calculation
Fairygui bar subfamily (scroll bar, slider, progress bar)
All in one 1405: sum and product of prime numbers
Role movement in the first person perspective
Fgui project packaging and Publishing & importing unity & the way to display the UI
一文搞定 UDP 和 TCP 高频面试题!
2022国赛Re1 baby_tree