当前位置:网站首页>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.
边栏推荐
猜你喜欢

jenkins use and maintenance

idea设置自动去除未引用(不再引用)的引用

接口性能测试方案设计方法有哪些?要怎么去写?

指令集数据产品如何设计和实现报表协同系统——基于指令集物联网操作系统的工业协同制造项目开发实践

2022年最新甘肃建筑施工焊工(建筑特种作业)模拟题库及答案解析

Hell Diggers Series #1

Qt uses QSortFilterProxyModel for sorting and filtering in QML

29岁从事功能测试被辞,面试2个月都找不到工作吗?

高数下|三重积分习题课|高数叔|手写笔记

Wincc报表教程(SQL数据库的建立,wincc在数据库中保存和查询数据,调用Excel模板把数据保存到指定的位置和打印功能)
随机推荐
jenkins搭建部署详细步骤
【无标题】
devops学习(九) Helm工具--持续部署
容器化 | 在 Rancher 中部署 MySQL 集群
windows下 PHP 安装
2022年最新甘肃建筑施工焊工(建筑特种作业)模拟题库及答案解析
rk-boot框架实战(1)
call、apply 以及 bind 的区别和用法
Redis系列:高可用之Sentinel(哨兵模式)
JSON.parseObject 带泛型告警
MySQL active/standby switch
2022年最新甘肃建筑八大员(材料员)模拟考试试题及答案
C陷阱与缺陷 第4章 链接 4.3 命名冲突与static修饰符
The latest Gansu construction welder (construction special operation) simulation question bank and answer analysis in 2022
一文解答web性能优化
Guidelines for the Release of New WeChat Mini Programs
深度学习的随机种子
MySQL六脉神剑,SQL通关大总结
devops学习(七) sonarqube 代码质检工具
[leetcode] 82. Delete duplicate elements in sorted linked list II (medium)