Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials
原文链接:Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials
Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials
TIPS
This article based on:a
- Spring Boot 2.1.5
- Spring Cloud Greenwich.SR1
- Spring Cloud Alibaba 0.9.0
- Nacos 1.0.0
1. What is Sentinel ?
With the popularity of microservices, the stability between services and services is becoming more and more important. Sentinel uses traffic as an entry point to protect the stability of services from multiple dimensions such as flow control, blowdown, and system load-balance protection.
In a nutshell, Sentinel is a lightweight flow control, blowdown and degraded Java library.
Sentinel has the following characteristics:
- Rich application scenarios:Sentinel undertakes the core scene of Alibaba's "Double Eleven" promotion traffic for nearly 10 years. For example, spikes (that is, burst flow control can be tolerated in the system capacity), message peaking and valley filling, cluster flow control, real-time fuse downstream applications that are not available.
- Complete real-time monitoring:Sentinel also provides real-time monitoring. You can see the single machine second-level data of the access application in the console, or even the aggregate operation of clusters of less than 500 sizes.
- Extensive open source ecology:Sentinel Provides out-of-the-box integration modules with other open source frameworks/libraries. For example, integration with Spring Cloud, Dubbo, gRPC. You only need to introduce the appropriate dependencies and perform a simple configuration to quickly access Sentinel.
- Complete SPI extension point:Sentinel provides an easy-to-use, comprehensive SPI expansion interface。You can quickly customize the logic by implementing an extension interface. Such as custom rule management, adapting dynamic data sources, etc.
2. Guides
Add dependencies:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
<version>0.2.1.RELEASE</version>
</dependency>
Add configurations:
server:
port: 8010
spring:
application:
# Specify the name of the service registered to the nacos server
name: microservice-consumer-movie
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
management:
endpoints:
web:
exposure:
include: '*'Add Controller:
@RequestMapping("/movies")
@RestController
public class MovieController {
@Autowired
private RestTemplate restTemplate; @GetMapping("/users/{id}")
public User findById(@PathVariable Long id) {
// Use the placeholder of the RestTemplate
User user = this.restTemplate.getForObject(
"http://microservice-provider-user/users/{id}",
User.class,
id
);
// ...Movie microservices business...
return user;
}
}
It can be seen from the code that this one can't be normal controller! Because Sentinel starter will provide a current limit for all HTTP services by default, the Controller can be protected by Sentinel (but there are no rules for configuring protection yet, so it has not been protected yet)!
3. Test
Access
http://localhost:8010/actuator/sentinel
,the following results can be obtained:{
"DegradeRules": [],
"datasources": {},
"ParamFlowRule": [],
"SystemRules": [],
"FlowRules": [],
"properties": {
"eager": false,
"enabled": true,
"datasource": {},
"transport": {
"port": "8719",
"dashboard": "localhost:8080",
"heartbeatIntervalMs": null
},
"metric": {
"fileSingleSize": null,
"fileTotalCount": null,
"charset": "UTF-8"
},
"servlet": {
"blockPage": null
},
"filter": {
"order": -2147483648,
"urlPatterns": ["/*"]
},
"flow": {
"coldFactor": "3"
},
"log": {
"dir": null,
"switchPid": false
}
}
}
At the moment, we don't know what the meaning of the result exposed by /actuator/sentinel
is. It doesn't matter, please read on.
4. Summary
Just add the spring-cloud-starter-alibaba-sentinel
dependency to your app, and all HTTP interfaces get Sentinel protection! Of course, we currently have no rules for configuring protection for Sentinel.
5. Sample Code
原文链接:Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials
转载,请保留原文地址,谢谢 ~
最新文章
- Security &#187; Authorization &#187; 基于视图的授权
- ODBC错误处理
- 走进AngularJs(七) 过滤器(filter) - 吕大豹
- [C/C++]C++标准中的名词
- String.Format格式说明
- LeetCode 232 Implement Queue using Stacks
- 关于 vim每次w时都提示 “E509: 无法创建备份文件 (请加 ! 强制执行)”
- EffectiveC#1--尽可能的使用属性(property),而不是数据成员(field)
- java整体集合框架
- 【学习opencv第七篇】图像的阈值化
- Sonar相关汇总
- 关于SESSION失效和关闭浏览器问题
- RabbitMQ学习笔记一:本地Windows环境安装RabbitMQ Server
- JAVA写接口傻瓜(!)教程(二)
- Cronolog日志分割、定时清理
- Oracle中 to_date和to_char用法
- is 和 == 区别,id() ,回顾编码,encode(),decode()
- 开机出现checking file system on C怎么办
- Codeword CodeForces - 666C (字符串计数)
- 51Nod 1376 最长递增子序列的数量 (DP+BIT)
热门文章
- 混合事务分析处理“HTAP”的技术要点分析
- LeetCode 230.二叉树中第k小的元素
- 使用mkfs.ext4格式化大容量磁盘
- Selenium+python上传本地文件或者图片
- Kilani and the Game-吉拉尼的游戏 CodeForce#1105d 模拟 搜索
- 整理总结 python 中时间日期类数据处理与类型转换(含 pandas)
- Exceptionless 5.0.0 本地Docker快速部署介绍
- mysql 5.7 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ...报错
- thymeleaf 遍历使用案例
- yii2 对字段 自动加一 或 减一