A introduction
What is Sentinel?
With the popularity of microservices, stability between services becomes increasingly important. Sentinel takes flow as the entry point to protect the stability of service from multiple dimensions such as flow control, fusing downgrading and system load protection.
Sentinel has the following characteristics:
- Rich application scenarios: Sentinel has undertaken the core scenarios of Alibaba’s double Eleven traffic drive in the past 10 years, such as SEC killing (i.e. burst traffic control within the range of system capacity), message peaking and valley filling, cluster flow control, real-time fusing of unavailable downstream applications, etc.
- Complete real-time monitoring: Sentinel also provides real-time monitoring capabilities. From the console, you can see a summary of the performance of a single machine-by-second data, or even a cluster of less than 500 machines, for accessing the application.
- Extensive Open source ecosystem: Sentinel provides out-of-the-box integration modules with other open source frameworks/libraries, such as Spring Cloud, Dubbo, and gRPC. You can quickly access Sentinel by introducing the appropriate dependencies and simple configuration.
- Sophisticated SPI extension points: Sentinel provides an easy-to-use, sophisticated SPI extension interface. You can quickly customize the logic by implementing an extension interface. For example, customize rule management and adapt dynamic data sources.
Key features of Sentinel:
Sentinel is divided into two parts:
- The core library (Java client) is independent of any framework/library, can run in all Java runtime environments, and has good support for frameworks such as Dubbo/Spring Cloud.
- The Console (Dashboard) is based on Spring Boot and can be packaged to run directly without the need for additional application containers such as Tomcat.
There is only so much about Sentinel on Alibaba’s website. Let’s use Sentinel briefly.
Sentinel is divided into server and client
The server side has a visual interface, easy to operate, the function is very powerful and practical.
If the client is a Maven project, jar needs to be introduced. As we all know, since the client is divided into the server and the client, the client must configure the address to connect to the server so that it can communicate with the server and complete the traffic limiting function.
2 the service side
Find the official address and download the JAR at github.com/alibaba/Sen…
Enter CMD in the address column to enter the command window. Then enter the command: Java -jar sentinel-dashboard-1.8.0.jar
Visit the web address: http://localhost:8080 The default user name and password are sentinell/sentinel, and then go to the home page
Now that the server setup is complete, spring Boot2 is used to integrate Sentinel
3 the client
Introduce dependencies in POM.xml
<! -- sentinel --> <dependency> <groupId>com.alibaba.cloud</groupId> < artifactId > spring -- cloud - starter - alibaba - sentinel < / artifactId > < version > 2.1.0. RELEASE < / version > < / dependency >Copy the code
Add configuration items to the configuration file
# sentinel Configure spring. Application. Name = service - apispring. Cloud. Sentinel. Transport. The dashboard = localhost: 8080 spring. Cloud. Sentinel. Trans port.heartbeat-interval-ms=500Copy the code
After the client service is started, you can view the client information on the server
There are flow control, degradation, hotspot, authorization and other operations, according to their own needs to configure, so the integration is completed.