当前位置:网站首页>Getting Started with Sentinel
Getting Started with Sentinel
2022-07-29 23:51:00 【Minor Wang Zhi】
Note outline
- Why flow control is needed
- Sentinel Concept
- Sentinel Console
- RPC framework integrates Sentinel
1. Distributed system traffic problems
In a distributed environment, there will be frequent dependency calls between multiple services. In the face of traffic floods, the resources of a node may be exhausted or the entire link may fail due to the call chain dependency.use.
Generally such solutions are:
- Call timeout mechanism: Once the maximum timeout time configured by the call is exceeded, the resource will be released immediately to prevent resource exhaustion.- Current limiting: Control the flow when a large flow arrives.- Fusing: Similar to the fuse of a circuit, when the call chain fails within a period of time or the number of timeouts reaches a certain threshold, it will trigger the same fuse logic as `trip`, because the call will continue to fail under high probability, avoidingWasteful consumption of resources.- Downgrade: Downgrade and fuse are complementary to each other. When a service node is blown, the caller must take some bottom-up or downgrade processing for this call logic.
2. Sentinel Concepts
Sentinel is a distributed service flow control component open sourced by Alibaba. It mainly uses traffic as the entry point to stabilize the service from multiple dimensions such as current limiting, traffic shaping, fuse degradation, load protection, and hotspot protection.Assure.
Sentinel has two core concepts: resources and rules; Resources
: The objects protected by Sentinel are collectively referred to as resources.rules
: The specific execution rules and policies of flow control and circuit breaker degradation support dynamic adjustment.
Sentinel components are the same as other microservice components, SpringBoot only needs to introduce a sentinel starter.There are 2 ways to enable Sentinel support in the project code:
- Hard-coded way, by configuring FlowRule to set specific resources and rules to be protected.
- Annotation method, @SentinelResource annotation can be added to the method, the method of table name is a resource to be protected by calling, and the traffic protection of the resource can be called through AOP technology.In the @SentinelResource annotation, you need to specify
blockHandler and fallback
, where blockFhandler handles exception handling thrown by Sentinel, and foallback represents normal business exceptions.
3. Sentinel Console
Sentinel provides a visual UI console interface, on which you can intuitively see the status and configuration information of microservices.Sentinel dashboard also needs to introduce POM dependencies.
Sentinel console can perform a series of monitoring and rule configuration:
- Real-time monitoring: Monitor the QPS and denial-of-service traffic of interface calls.
- Cluster point link: Displays the list of APIs monitored by the microservice.
- Flow control rules: The traffic entry points are: QPS, number of threads.The flow control modes are: direct, association, link.Flow control effects include: fail fast, warm up, and wait in line.
- Current limit of hotspot parameters: Control the flow of frequently called interface resources.
4.RPC framework integration Sentinel
4.1 RestTemplate Integration with Sentinel
RestTemplate integrates Sentinel circuit breaker support by adding the @SentinelRestTemplate
annotation to the Bean method that constructs the RestTemplate. In the annotation, you can configure specific current limiting and downgrade configurations.
4.2 Feign Integration with Sentinel
First, you need to turn on feign.sentinel.enabled=true in the yml configuration file, and then configure the fallback processing downgrade method on the @FeignClient annotation.
边栏推荐
- Vulkan与OpenGL对比——Vulkan的全新渲染架构
- 【leetcode】The sword refers to Offer II 002. Binary addition
- 【小程序项目开发-- 京东商城】uni-app之自定义搜索组件(下) -- 搜索历史
- Tkinter:功能按钮Button
- 微信小程序获取手机号getPhoneNumber接口报错44002
- devops学习(六)Jenkins 持续部署-版本选择
- 很遗憾,没有一篇文章能讲清楚分布式事务
- Android 11 : 隐私和安全
- 在树莓派上安装 PyCharm
- The Sandbox Partners with Gravity to Bring RO Ragnarok to the Metaverse
猜你喜欢
随机推荐
go语言序列化和反序列化及序列化后的json为空和json的key值大写如何改为小写问题
devops学习(三) K8环境部署jenkins
读书笔记:《这才是心理学:看穿伪心理学的本质(第10版)》
JetsonNano learning (6) Big pits and solutions that Jetson stepped on___Continuously updated
标签分发协议(LDP)
能源企业数字化转型背景下的数据安全治理实践路径
C陷阱与缺陷 第5章 库函数 5.1 返回整数的getchar函数
C陷阱与缺陷 第4章 链接 4.3 命名冲突与static修饰符
JetsonNano learning (5) JetsonNano installs PyTorch and Torchvision
Gao Shu Xia|Triple Integral Exercises|Uncle Gao Shu|Handwritten Notes
MySQL事务隔离级别详解
50. Leetcode 】 【 Pow (x, n) (medium) (power) quickly
卧槽,2行代码,让接口性能提升10倍
JVM初探- 内存分配、GC原理与垃圾收集器
Windows 安装 MySQL 5.7详细步骤
DFS对树的遍历及一些优化
重庆OI 2005 新年好
高数下|三重积分的计算3|高数叔|手写笔记
Framework 到底该怎么学习?
shell编写规范和变量