当前位置:网站首页>[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 ;

边栏推荐
- New year's goals! The code is more standardized!
- Sharing of four open source face recognition projects
- NIO this.selector.select()
- HUAWEI 机试题:火星文计算 js
- BEVFormer: Learning Bird’s-Eye-View Representation from Multi-Camera Images via Spatiotemporal Trans
- CUDA programming-01: build CUDA Programming Environment
- 07_ Service registration and discovery summary
- Arm undefined instruction exception assembly
- Restful
- 基于restful页面数据交互
猜你喜欢

500 error reporting

Intel, squeezed by Samsung and TSMC, finally put down its body to customize chip technology for Chinese chips

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

How to deploy yolov6 with tensorrt

Low cost, low threshold, easy deployment, a new choice for the digital transformation of 48 million + small and medium-sized enterprises

The shelf life you filled in has been less than 10 days until now, and it is not allowed to publish. If the actual shelf life is more than 10 days, please truthfully fill in the production date and pu

对 int 变量赋值的操作是原子的吗?

8 kinds of visual transformer finishing (Part 1)

4274. Suffix expression

Specific methods and steps for Rockwell AB PLC to establish communication with PLC through rslinx classic
随机推荐
Built in method of tensorflow model training and evaluation
Deep understanding of Kalman filter (2): one dimensional Kalman filter
Interface test tool - JMeter pressure test use
Understand various IOU loss functions in target detection
vscod
08_ Service fusing hystrix
【每日算法Day 94】经典面试题:机器人的运动范围
易语言编程: 让读屏软件可获取标签控件的文本
JS detects whether the client software is installed
[daily algorithm day 96] Tencent interview question: merge two ordered arrays
[interprocess communication IPC] - semaphore learning
Huawei machine test question: Martian computing JS
How to study happily on station B?
Full Permutation (depth first, permutation tree)
2034: [Blue Bridge Cup 2022 preliminary] pruning shrubs
Aruba learning notes 10 security authentication portal authentication (web page configuration)
New year's goals! The code is more standardized!
NIO this.selector.select()
微信安装包从0.5M暴涨到260M,为什么我们的程序越来越大?
E. Split into two sets