[Sentinel2]-Introduction to Sentinel

1.2.1. What is Sentinel

Sentinel (Flow Guard for Distributed Systems) is an open source flow control framework for service fault tolerance . It uses traffic as an entry point to protect the stability of services from multiple dimensions such as traffic control and circuit breaker degradation .

Official Website: quick-start | Sentinel

1.2.2. Main functions of Sentinel

The main function of Sentinel is fault tolerance , which is mainly reflected in the following two aspects:

  • flow control

    • Monitor QPS : Control when the QPS of calling this interface reaches the threshold(不被上游服务压垮)

 

  • Monitor the number of threads : assign independent threads to each interface, and when a fault occurs, the problem can be isolated internally without spreading(不被下游服务拖垮)

 

  • Fuse downgrade

    When the ratio of slow calls or abnormal ratios of a resource exceeds the threshold, the calls to downstream services are temporarily cut off to avoid cascading failures

 

In a word, what we need to do is to configure various rules on Sentinel resources to achieve various fault-tolerant functions:

 

1.2.3. Installation and start of Sentinel

Sentinel provides a lightweight console that provides real-time resource monitoring and rule management functions.

  1. Download address: Release v1.8.3 · alibaba/Sentinel · GitHub

 

2. Execute the command:java -jar sentinel-dashboard-1.8.3.jar

 

3. Browser access: http://localhost:8080 , default account password: sentinel/sentinel

 

1.2.4. Sentinel access console

1.2.4.1.order-service

1.2.4.1.1.pom.xml

<!-- sentinel launcher -->
<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

1.2.4.1.2.application.yml

spring:
  cloud:
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080 #Specify the address of sentinel

1.2.4.1.3.controller

/**
 *Protected logic
 */
@RequestMapping(value = "/hello")
public String hello() {
    return "Hello Sentienl!!!";
}

1.2.4.2. Testing

  1. Traffic monitoring: sentinel is lazy loading and requires browser access: http://localhost:8002/hello

 

​​​​​​​

 

  1. Add flow control rules

 

 

 

QPS: Represents the number of visits per second, as long as the number of visits reaches a certain threshold, the current limit operation will be performed

  1. High concurrent access: http://localhost:8002/hello

 

 

Guess you like

Origin blog.csdn.net/listeningdu/article/details/128584091