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
转载,请保留原文地址,谢谢 ~
Sentinel Getting Started And Integration of Spring Cloud Alibaba Tutorials的更多相关文章
- Spring Cloud Alibaba迁移指南(一):一行代码从 Hystrix 迁移到 Sentinel
摘要: 本文对Hystrix.Resilience4j.Sentinel进行对比,并探讨如何使用一行代码这种极简的方式,将Hystrix迁移到Sentinel. Hystrix 自从前段时间 宣布停止 ...
- Spring Cloud Alibaba基础教程:Sentinel使用Apollo存储规则
上一篇我们介绍了如何通过Nacos的配置功能来存储限流规则.Apollo是国内用户非常多的配置中心,所以,今天我们继续说说Spring Cloud Alibaba Sentinel中如何将流控规则存储 ...
- Spring Cloud Alibaba基础教程:Sentinel使用Nacos存储规则
通过上一篇<使用Sentinel实现接口限流>的介绍,相信大家对Sentinel已经有了初步的认识.在Spring Cloud Alibaba的整合封装之下,接口限流这件事情可以非常轻易的 ...
- Spring Cloud Alibaba基础教程:使用Sentinel实现接口限流
最近管点闲事浪费了不少时间,感谢网友libinwalan的留言提醒.及时纠正路线,继续跟大家一起学习Spring Cloud Alibaba. Nacos作为注册中心和配置中心的基础教程,到这里先告一 ...
- Spring Cloud Alibaba Sentinel 整合 Feign 的设计实现
作者 | Spring Cloud Alibaba 高级开发工程师洛夜 来自公众号阿里巴巴中间件投稿 前段时间 Hystrix 宣布不再维护之后(Hystrix 停止开发...Spring Cloud ...
- Spring Cloud Alibaba基础教程:Sentinel Dashboard中修改规则同步到Nacos
上一篇我们介绍了如何通过改造Sentinel Dashboard来实现修改规则之后自动同步到Apollo.下面通过这篇,详细介绍当使用Nacos作为配置中心之后,如何实现Sentinel Dashbo ...
- Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探
目录 Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探 1. Sentinel 是什么? 2. Sentinel 的特征: 3. Sentinel 的开源生 ...
- Spring Cloud Alibaba | Sentinel: 服务限流基础篇
目录 Spring Cloud Alibaba | Sentinel: 服务限流基础篇 1. 简介 2. 定义资源 2.1 主流框架的默认适配 2.2 抛出异常的方式定义资源 2.3 返回布尔值方式定 ...
- Spring Cloud Alibaba | Sentinel: 服务限流高级篇
目录 Spring Cloud Alibaba | Sentinel: 服务限流高级篇 1. 熔断降级 1.1 降级策略 2. 热点参数限流 2.1 项目依赖 2.2 热点参数规则 3. 系统自适应限 ...
随机推荐
- 阿里云服务器CentOS7.3上通过Docker安装MySQL
一.前言 我的服务器环境: CentOS7.3 Docker Portainer -> Docker可视化界面工具 二.拉取mysql镜像 这里我安装的是mysql5.7版本 docker pu ...
- 卷积层后连接LSTM层的报错(InvalidArgumentError (see above for traceback): Incompatible shapes: [128] vs. [384])
三通道编译通过但无法训练 报错 InvalidArgumentError (see above for traceback): Incompatible shapes: [128] vs. [384] ...
- Java图片处理:ico格式转 PNG/JPG等格式
一. 什么是ico图标? ico是一种图标格式,大量应用于网站,各个软件的logo或图标展示. 我们在进入某个网站或网页,它们上方标题左侧各自都带有logo图标. 这就是favicon.ico图标,它 ...
- 理解JavaScript中的this关键字
JavaScript中this关键字理解 在爬虫的过程中遇到了前端的js代码,对于this关键字理解的不是很清楚,所以写下这篇笔记,不足之处,希望得以改之. this的指向在函数定义的时候无法确定,只 ...
- WPS删除多余空白页
WPS删除多余空白页 在实际工作中,我们在操作WPS文字的时候常常会遇到一种问题,就是当在文字占满整页的时候,文档常常会多出一页空白页的现象.如图1 图 1 对于WPS文字怎么删除空白页这个问题, ...
- 如何看破真假美猴王 ? --java中的Shadowing和Obscuring
故事背景 <西游记>第五十七回:唐僧因悟空又打死拦路强盗,再次把他撵走.六耳猕猴精趁机变作悟空模样,抢走行李关文,又把小妖变作唐僧.八戒.沙僧模样,欲上西天骗取真经.真假二悟空从天上杀到地 ...
- Spring MVC 梳理 - handlerMapping和handlerAdapter分析
参考图片 综上所述我们来猜测一下spring mvc 中根据URL找到处理器Controller中相应方法的流程 ①:获取Request的URL ②:从UrlLookup这个map中找到相应的requ ...
- Player的跟踪狂 -- Camera
P.S.很多游戏里的Player都会设置的被跟踪,是人性的扭曲,还是XXX,正在解密. 第三人称视角 camera紧跟player背后(角度随player改变) using System.Collec ...
- markdown常用语法使用笔记
markdown是当下比较流行的一种编辑标记语言,很多系统都支持markdown语法来编辑文件内容,像gitbook之类的,一下是一些学习笔记. 1.开头用#的数量表示1-6阶的标题,结尾可以以任意数 ...
- go语言标准库之http/template
html/template包实现了数据驱动的模板,用于生成可对抗代码注入的安全HTML输出.它提供了和text/template包相同的接口,Go语言中输出HTML的场景都应使用text/templa ...