The environment
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5. RELEASE</version>
<relativePath/> <! -- lookup parent from repository -->
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.1. RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Copy the code
The service side Sentinel – dashboard
- Download the latest
Sentinel-dashboard
The jar package
Github.com/alibaba/Sen…
- Run the jar package
Java jar sentinel - dashboard - 1.7.1. Jar - Dserver. Port = 8080 - Dcsp. Sentinel. Dashboard. Server = localhost: 8080 -Dproject.name=sentinel-dashboardCopy the code
- Browser access
http://localhost:8080
Default password Sentinel /sentinel
The client
Introduction of depend on
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
Copy the code
-
Postman or curl calls the in-program interface, and real-time monitoring can be seen in sentinel Dashboard
-
Configure traffic limiting rules click cluster link → Select interface → Click Flow Control
Implementation effect (traffic limiting policy) : A maximum of two requests are allowed per second threshold type: QPS Single-machine threshold: 2Copy the code
Interface test, quick call third by Sentinel flow limiting