Spring Cloud Sentinel Actual Combat (1) - Introduction to Sentinel

Introduction to Sentinel

What is Sentinel?

  1. Traffic guards for distributed systems : With the popularity of microservices, the stability of service calls has become more and more important. Sentinel takes "flow" as the entry point, and works in multiple fields such as flow control, circuit breaking, and load protection to ensure service reliability.

  2. Features:
    1.
    2. + Abundant application scenarios : Sentinel has undertaken the core scenarios of Alibaba’s Double Eleven traffic promotion in the past 10 years, such as seckill (that is, burst traffic is controlled within the range that the system capacity can bear), message cutting Peak filling and valley filling, cluster flow control, real-time fusing of downstream unavailable applications, etc.
    3. Complete real-time monitoring : Sentinel also provides real-time monitoring functions. In the console, you can see the second-level data of a single machine connected to the application, or even the aggregated running status of a cluster with a scale of less than 500.
    4. Extensive open source ecosystem : Sentinel provides out-of-the-box integration modules with other open source frameworks/libraries, such as integration with Spring Cloud, Apache Dubbo, gRPC, and Quarkus. You only need to introduce the corresponding dependencies and perform simple configurations to quickly access Sentinel. At the same time, Sentinel provides multi-language native implementations such as Java/Go/C++.
    5. Perfect SPI extension mechanism : Sentinel provides an easy-to-use and complete SPI extension interface. You can quickly customize the logic by implementing the extension interface. For example, custom rule management, adaptation of dynamic data sources, etc.

  3. Official website document: https://github.com/alibaba/Sentinel/wiki/%E4%BB%8B%E7%BB%8D

Sentinel benefits

​ Problems faced by distributed systems: applications in complex architectures have dozens of dependencies, and each dependency will inevitably fail at some point. For example, in the following example, when we call A, E, When there is a problem with one of the services of F, J, and K, what problems will it cause? In fact, the overall system efficiency will all drop, and there will be a serious problem of service avalanche !

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-lc1zvlHe-1677421647273)(image-20211005013321645.png)]

​Service Avalanche:

​ When multiple microservices are called, suppose A calls B and C, and B and C call other microservices. This is the so-called fan-out . If the response time process of a microservice call on a fan-out link is unavailable, the call of microservice A will occupy more and more system resources, causing the system to crash, which is a service avalanche . In fact, the high availability of the service has been destroyed.

For high-traffic applications, a single backend dependency can cause all resources on the server to be saturated within seconds. It is also possible for these applications to cause increased latency between services, backup queues, threads and other system resource strains, leading to more cascading failures throughout the system. These all indicate the need to isolate and manage failures and delays so that a single dependency fails and the entire application or system cannot be canceled, so usually after an instance of a module fails, the module will still accept traffic at this time, The offending module then calls other modules, and a cascading failure, or avalanche , occurs .

To solve this kind of problem, we need to use service degradation, and Sentinel can ensure that in the case of a dependency problem, it will not cause the overall service to fail, avoid cascading failures, and improve the elasticity of the distributed system.

​Sentinel 's fuse downgrade is implemented through circuit breakers:

​ Circuit breaker: It is a switching device itself. When a service unit fails, through the fault monitoring of the circuit breaker (similar to blowing a fuse), an expected and processable alternative response is returned to the caller ( FallBack), instead of waiting for a long time or throwing an exception that cannot be thrown by the calling method, this ensures that the service caller will not be occupied for a long time and unnecessary, thus avoiding the spread of faults in the distributed system (similar to due to virus infection), thereby avoiding the spread of faults in the system, and even crashes.

​Benefits :

​ Compared with other products, such as Hystrix, it does not require us to manually build a monitoring platform, and it has a set of web interfaces similar to Nacos, which allows us to configure more fine-grained flow control, rate, and service fusing , service downgrade, etc.

​ At present, mainstream programming is convention > configuration > code. Although our configuration can be written in the code, we still need to learn the configuration and annotation methods on a large scale, and try to use as little code as possible. This is also the philosophy and original intention of Sentinel.

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-z45RYVUS-1677421647274)(image-20211005004311575.png)]

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-ksegqcRs-1677421647275)(image-20211005004335733.png)]

Sentinel download and installation

​ Download address: https://github.com/alibaba/Sentinel/releases

[External link picture transfer failed, the source site may have an anti-theft link mechanism, it is recommended to save the picture and upload it directly (img-fv0yp4Uq-1677421647275)(image-20211005005114846.png)]

Official manual: https://spring-cloud-alibaba-group.github.io/github-pages/hoxton/en-us/index.html#_spring_cloud_alibaba_sentinel

Sentinel is divided into two parts

  • The core library (Java client) does not depend on any framework/library, only needs the Java runtime environment, and also has good support for Dubbo/SpringCloud and other frameworks.
  • The console (Dashboard) is developed based on SpringBoot and can be run directly after packaging without additional application containers such as Tomcat.

startup steps

  • Premise: jdk1.8 environment and port 8080 cannot be occupied

  • Start command: java -jar sentinel-dashboard-1.8.2.jar

  • Access address: localhost:8080

  • Enter the default account password: sentinel/sentinel

    [External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-nhGFycbd-1677421647275)(image-20211005010854771.png)]

    [External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-s1WdRQbz-1677421647276)(image-20211005010930366.png)]

insert image description here

So far, our Sentinel installation is successful.

Guess you like

Origin blog.csdn.net/qq_27566167/article/details/129232884