当前位置:网站首页>[micro service ~sentinel] sentinel dashboard control panel
[micro service ~sentinel] sentinel dashboard control panel
2022-07-27 09:02:00 【Classmate Tao Ran】

Here is 【 Microservices ~Sentinel】, Pay attention to me to learn micro services without getting lost
If it helps you , Give the blogger a free praise to show encouragement
You are welcome to comment on the collection ️
Column introduction
【 Microservices ~Sentinel】 At present, it mainly updates micro services , Learn together and progress together .
Introduction to this issue
This issue focuses on Sentinel And dashboard Control panel
List of articles
Set resource point ( Buried point )
The difference between current limiting and degradation
dashboard Control panel
summary
Sentinel Dashboard It's an independent project ,sentinel-dashboard-1.8.4.jar, Need to use java -jar function
java -jar -Dserver.port=18080 sentinel-dashboard-1.8.4.jar

Download address
To configure dashboard
Add coordinates ( existing )
<!-- Downgrade -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
To configure yml
#server.port=8071
#spring.application.name=service-consumer
#spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848
#spring.cloud.sentinel.transport.dashboard=192.168.152.153:8080
# Port number
server:
port: 8071
spring:
application:
name: service-consumer # service name
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848 #nacos Service address
sentinel:
transport:
dashboard: 127.0.0.1:18080
feign:
sentinel:
enabled: true
test
Access resources first
http://localhost:8071/feign/echo/123dashboard Sign in

Look at the control panel http://localhost:18080/

Set resource point ( Buried point )
adopt @SentinelResource annotation , Set monitoring point ( Define control resources 、 Configure the control policy )
package com.czxy.nacos.controller;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.czxy.nacos.feign.TestFeign;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/feign")
public class TestFeignController {
@Resource
private TestFeign testMyFeign;
@RequestMapping(value = "/echo/{str}", method = RequestMethod.GET)
@SentinelResource("/feign/echo")
public String echo(@PathVariable String str) {
return testMyFeign.echo(str);
}
}
test

Current limiting
Writing test classes

package com.czxy.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
@GetMapping("/login")
public String login(String str) {
return " Login successful " + str;
}
@GetMapping("/register")
public String register(String str) {
return " Registered successfully ";
}
}
Current limiting method
adopt
@SentinelResourceAnnotatedblockHandlerProperty specifies the current limiting handler
package com.czxy.nacos.controller;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
@GetMapping("/login")
// Current limiting setting
@SentinelResource(value="login", blockHandler = "loginBlockHandler")
public String login(String str) {
return " Login successful " + str;
}
public String loginBlockHandler(String str , BlockException e) {
return str + ": Please try again later ";
}
@GetMapping("/register")
public String register(String str) {
return " Registered successfully ";
}
}
Current limiting operation
function sentinel-dashboard-1.8.4.jar
Access test functions :http://localhost:8071/user/login?str=1234
adopt dashboard Set current limiting

Continuous fast 2 Access test function

Fusing the drop
Degradation method
Use @SentinelResource Annotated fallback Property to specify the degraded method name
package com.czxy.controller;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.apache.commons.lang.math.RandomUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/user")
public class UserController {
@GetMapping("/login")
// Current limiting setting
@SentinelResource(value="login", blockHandler = "loginBlockHandler")
public String login(String str) {
return " Login successful " + str;
}
public String loginBlockHandler(String str , BlockException e) {
return str + ": Please try again later ";
}
@GetMapping("/register")
// Fusing the drop
@SentinelResource(value="register", fallback = "registerFallback")
public String register(String str) {
int r = RandomUtils.nextInt(10);
if(r < 5) {
int i = 1 / 0;
}
return " Registered successfully ";
}
public String registerFallback(String str) {
return str + ": Fusing the drop ";
}
}test
success

Fusing the drop

Degraded operation
Slow call ratio :
RT: Mean response time
Scale threshold :
Duration of fusing :
Minimum number of requests :
Abnormal proportion : The ratio of the total number of exceptions per second to the throughput exceeds the threshold (DegradeRule Medium count) after , Resources go into a degraded state
Number of abnormal : When resources are near 1 After the number of exceptions exceeds the threshold, it will fuse

The difference between current limiting and degradation
Current limiting is achieved by setting QPS( Query rate per second )/ Number of threads , Reject the part exceeding the threshold ;
Service degradation is to monitor request response time 、 Response exception ratio 、 Number of exceptions ; Threshold exceeded , The service will be degraded and blown , Not available for a certain period of time ;

边栏推荐
- NIO示例
- 2040: [Blue Bridge Cup 2022 preliminary] bamboo cutting (priority queue)
- The execution sequence of async/await, macro tasks and micro tasks
- Huawei machine test question: Martian computing JS
- Matlab画图技巧与实例:堆叠图stackedplot
- Redis network IO
- 500报错
- 5G没能拉动行业发展,不仅运营商失望了,手机企业也失望了
- Pyqt5 rapid development and practice 4.1 qmainwindow
- Is it safe to buy funds every day? Online and other answers
猜你喜欢

Explain cache consistency and memory barrier

E. Split into two sets
![Software testing function testing a full set of common interview questions [function testing - zero foundation] essential 4-1](/img/1c/c1c1b15e502ee901a396840c01e84d.png)
Software testing function testing a full set of common interview questions [function testing - zero foundation] essential 4-1

Arm system call exception assembly

Restful

Mangodb simple to use

NIO this.selector.select()

【ACL2020】一种新颖的成分句法树序列化方法

一些实用、常用、效率越来越高的 Kubernetes 别名

Some practical, commonly used and increasingly efficient kubernetes aliases
随机推荐
Babbitt | yuan universe daily must read: Guangzhou Nansha released the "Yuan universe nine" measures, and the platform can obtain up to 200million yuan of financial support
PVT的spatial reduction attention(SRA)
02 linear structure 3 reversing linked list
Tensorflow package tf.keras module construction and training deep learning model
【ACL2020】一种新颖的成分句法树序列化方法
四个开源的人脸识别项目分享
A survey of robust lidar based 3D object detection methods for autonomous driving paper notes
Matlab uses m file to produce fuzzy controller
微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
Explain cache consistency and memory barrier
博客怎么上传动态gif图
Some practical, commonly used and increasingly efficient kubernetes aliases
PyQt5快速开发与实战 4.1 QMainWindow
Primary function t1744963 character writing
500报错
音乐体验天花板!14个网易云音乐的情感化设计细节
[interprocess communication IPC] - semaphore learning
Matlab 利用M文件产生模糊控制器
如何在B站上快乐的学习?
QT uses SQLite to open multiple database files at the same time