当前位置:网站首页>What is sentinel produced by Ali?

What is sentinel produced by Ali?

2022-06-11 06:18:00 Milo_

Hello, Hello everyone , This is Milo , Let's take you to know about Sentinel, This article mainly introduces what is Sentinel And how we build it Sentinel Console , Prepare for the follow-up study ;

Sentinel brief introduction

 

image.png

 

Sentinel It's an open source project of Ali , Positioned as a highly available flow control component for distributed service-oriented architecture . The main pointcut is traffic , Slave flow control 、 Fusing the drop 、 System adaptive protection and other dimensions to help users ensure the stability of micro services .

 

Sentinel Introduce

With the popularity of microservices , Stability between services and services is becoming more and more important .Sentinel emerge as the times require .

Sentinel The history of

  • 2012 year ,Sentinel Be born , The main function is inlet flow control .
  • 2013-2017 year ,Sentinel It is developing rapidly within Alibaba group , Become the basic technology module , Covering all the core scenarios .Sentinel As a result, a large number of traffic consolidation scenarios and production practices have been accumulated .
  • 2018 year ,Sentinel Open source , And continue to evolve .
  • 2019 year ,Sentinel Explore the direction of multilingual expansion , Introduction C++ Native version , Also aim at Service Mesh The scene also came out Envoy Cluster traffic control support , To solve the problem Service Mesh The problem of multi language flow restriction under the framework .
  • 2020 year , Introduction Sentinel Go edition , Continue to evolve towards cloud Nativity .

Sentinel Developer Introduction

Never forget the digger when drawing water , Thanks to these guys

 

image.png

Sentinel The main characteristics of


image

 

Sentinel In two parts :

  • Core library (Java client ) Don't rely on any framework / library , Can run on all Java Runtime environment , At the same time Dubbo / Spring Cloud And other frameworks also have better support .
  • Console (Dashboard) be based on Spring Boot Development , It can run directly after packing , No additional Tomcat Etc. Application containers .

Sentinel Basic concepts

resources

Resources are Sentinel Key concepts of . It can be Java Anything in the application , for example , Services provided by applications , Or services provided by other applications called by the application , It could even be a piece of code . In the next document , We all use resources to describe code blocks .

As long as through the Sentinel API Defined code , It's resources , It can be Sentinel Protect it . In most cases , You can use method signature ,URL, Even the service name identifies the resource as the resource name .

The rules

Rules around the real-time state of resources , It can include flow control rules 、 Fusing degradation rules and system protection rules . All rules can be adjusted dynamically and in real time .

Sentinel Function and design concept

flow control

Flow control is a common concept in network transmission , It is used to adjust the sending data of network packets . However , From the perspective of system stability , In terms of the speed of processing requests , There is also a lot of stress . Requests coming at any time are often random and uncontrollable , And the processing power of the system is limited . We need to control the flow according to the processing capacity of the system .Sentinel As a tuner , You can adjust random requests to the right shape as needed , As shown in the figure below :

image

Flow control has the following angles :

  • Resource call relationship , For example, the call link of resources , The relationship between resources ;
  • Operation index , for example QPS、 Thread pool 、 System load, etc ;
  • The effect of control , For example, direct current limiting 、 Cold start 、 Line up, etc .

Sentinel The design concept is to let you freely choose the angle of control , And flexible combination , So as to achieve the desired effect .

Fusing the drop

What is a fuse demotion

In addition to flow control , Reducing unstable resources in the call link is also Sentinel One of my missions . Because of the complexity of the call relationship , If a resource in the call link is unstable , It will eventually cause requests to pile up . The question is the same as Hystrix The problem described in it is the same .

image

Sentinel and Hystrix The principles of are the same : When a resource in the call link is unstable , for example , Manifested as timeout, When the proportion of anomalies increases , Then limit the call of this resource , And let the request fail quickly , Avoid affecting other resources , Eventually, it's an avalanche effect .

The concept of design

In the means of restriction ,Sentinel and Hystrix In a completely different way .

Hystrix adopt Thread pool The way , To depend on ( In our concept, the corresponding resources ) It was isolated . The advantage of this is the most thorough isolation between resources . The disadvantage is that in addition to increasing the cost of thread switching , We also need to allocate the size of thread pool to each resource in advance .

Sentinel There are two approaches to this problem :

  • Limit by the number of concurrent threads

Unlike resource pool isolation ,Sentinel By limiting the number of resource concurrent threads , To reduce the impact of unstable resources on other resources . In this way, there is no loss of thread switching , There is no need for you to pre allocate the size of the thread pool . When a resource is unstable , For example, the response time becomes longer , The direct impact on resources is the gradual accumulation of threads . When the number of threads has accumulated to a certain number on a specific resource , New requests for this resource will be rejected . The stacked threads do not start receiving requests until they have completed their tasks .

  • Demote resources through response time

In addition to controlling the number of concurrent threads ,Sentinel You can also quickly degrade unstable resources through response time . When the response time of dependent resources is too long , All access to the resource will be directly denied , Do not restore until after the specified time window .

System load protection

Sentinel At the same time provide Adaptive protection capability of system dimension . Prevent avalanche , It's an important part of system protection . When the system load is high , If the request continues to enter , May cause system crash , Unable to respond . In a cluster environment , Network load balancing will forward the traffic that should be carried by this machine to other machines . If other machines are in an edge state at this time , This increased traffic will cause the machine to crash , Finally, the whole cluster is not available .

In response to this situation ,Sentinel The corresponding protection mechanism is provided , Make the system's inlet flow and the system's load reach a balance , Ensure that the system processes the most requests within its capabilities .

Sentinel How it works

Sentinel The main working mechanism is as follows :

  • Provide adaptation or display for mainstream framework API, To define the resources that need to be protected , And provide facilities for real-time statistics of resources and call link analysis .
  • According to the preset rules , Combined with real-time statistics of resources , Control the flow . meanwhile ,Sentinel Provide an open interface , It's convenient for you to define and change the rules .
  • Sentinel Provide real-time monitoring system , Convenient for you to quickly understand the status of the current system .

 

 

Sentinel Console construction

 

1. First, we need to go to the official website to download jar package

https://github.com/alibaba/Sentinel/releases

image.png

 

2. open jar Package directory , And open the command line window

image.png

 

3. start-up

Be careful : start-up Sentinel Console need JDK Version is 1.8 And above .

java -Dserver.port=8080 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar

explain

among -Dserver.port=8080 Is used to specify the Sentinel The console port is 8080

If you have already downloaded other versions jar package , Please send the command sentinel-dashboard-1.8.1.jar Replace it with yours jar Package name

image.png

4.sentinel.dashboard It's just one. springboot engineering , You can see that the project is already 8080 Port boot

image.png

5. Enter... In the browser url:localhost:8080 Then you can enter the main page .

image.png

 

6. After successful login, it is shown in the following figure

image.png

 

 

原网站

版权声明
本文为[Milo_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020528131399.html