雪崩效应:在微服务分布式系统中,服务间都是相互调用的,不考虑外部因素,当服务A不可用时,调用服务A的服务B则会强制等待直至超时,一个请求对应一个线程,强制等待即线程阻塞,在请求超时时这个线程才会被释放,在高并发的应用系统中,随着时间推移,到最后线程会被耗尽,服务B也不可用。下层服务导致上层服务不可用并逐渐扩大服务范围。
常见容错方案
- 超时
- 限流
- 仓壁模式
- 断路器
整合Sentinel
- 依赖
<dependency> <groupId>com.alibaba.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> 复制代码
management:
endpoints:
web:
exposure:
include: '*'
复制代码
-
启动访问
http://localhost:9001/actuator/sentinel
,响应结果如下则整合成功
{ "appName":"mg-user-service", "consoleServer":"localhost:8080", "coldFactor":"3", "rules":{ "systemRules":[], "authorityRule":[], "paramFlowRule":[], "flowRules":[], "degradeRules":[] }, "metricsFileCharset":"UTF-8", "filter":{ "order":-2147483648, "urlPatterns":[ "/*" ], "enabled":true }, "totalMetricsFileCount":6, "datasource":{}, "clientIp":"192.168.0.102", "clientPort":"8719", "logUsePid":false, "metricsFileSize":52428800, "logDir":"/Users/gaozaoshun/logs/csp/" } 复制代码
原文
https://juejin.im/post/5eecdb56e51d4574275e11bc
本站部分文章源于互联网,本着传播知识、有益学习和研究的目的进行的转载,为网友免费提供。如有著作权人或出版方提出异议,本站将立即删除。如果您对文章转载有任何疑问请告之我们,以便我们及时纠正。PS:推荐一个微信公众号: askHarries 或者qq群:474807195,里面会分享一些资深架构师录制的视频录像:有Spring,MyBatis,Netty源码分析,高并发、高性能、分布式、微服务架构的原理,JVM性能优化这些成为架构师必备的知识体系。还能领取免费的学习资源,目前受益良多

转载请注明原文出处:Harries Blog™ » 微服务之限流降级Sentinel