前言:不断学习就是程序员的宿命
Github官网:https://github.com/alibaba/Sentinel,就是SpringCloud的Hystrix
下载地址:https://github.com/alibaba/Sentinel/releases
java -jar sentinel-dashboard-1.7.0.jar
浏览器访问:http://localhost:8080/,用户名密码均为:sentinel
以下设置表示:1秒钟内查询1次就是OK,若次数超过1,就直接-快速失败,报默认错误
当关联的资源达到阈值时,就限流自己;当与A关联的资源B达到阈值时,就限流A自己(B惹事,A挂了)
设置:当关联资源/testB的qps阈值超过1时,就限流/testA的Rest访问地址,当关联资源达到阈值后限制配置好的资源名。
Github:https://github.com/alibaba/Sentinel/wiki/Flow-Control
直接失败,抛出异常:Blocked by Sentinel(flow limiting)
源码:com.alibaba.csp.sentinel.slots.block.flow.controller.DefaultController
默认coldFactor为3,即请求QPS从threshold/3开始,经预热时长逐渐升至设定的QPS阈值。限流冷启动
以下是指开始QPS为10/3=3,5秒后慢慢预热至10
匀速排队,阈值必须设置为QPS(漏桶算法)
源码:com.alibaba.csp.sentinel.slots.block.flow.controller.RateLimiterController
以下设置含义:/testA每秒1次请求,超过的话就排队等待,等待的超时时间为20000毫秒。
SpringCloud Alibaba Sentinel---实现熔断与限流
原文:https://www.cnblogs.com/rmxd/p/12595041.html