既然用到了feign,那么主要是针对服务消费方的降级处理.我们基于0.9.0.RELEASE版本的spring cloud alibaba nacos+feign实例添油加醋,把sentinel功能加上去: 1.pom引入sentinel依赖: <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-alibaba-sentinel&…
先看服务提供方的,我们在原来的sentinel实例(参见0.9.0.RELEASE版本的spring cloud alibaba sentinel实例)上加上限流.降级处理,三板斧只需在最后那一斧controller类中做如下修改: @Slf4j @RestController static class TestController { @Autowired private TestService testService; @GetMapping("/hello") public St…
sentinel即哨兵,相比hystrix断路器而言,它的功能更丰富.hystrix仅支持熔断,当服务消费方调用提供方发现异常后,进入熔断:sentinel不仅支持异常熔断,也支持响应超时熔断,另外还支持限流,以及针对网关的熔断和限流.此外,它还有过载处理.监控控制台(Sentinel Dashboard)等.hystrix作为组件集成到微服务中,sentinel也是如此,但它的控制台需要独立部署. 先下载Sentinel Dashboard(下载地址https://github.com/ali…
sentinel除了让服务提供方.消费方用之外,网关也能用它来限流.我们基于上次整的网关(参见0.9.0.RELEASE版本的spring cloud alibaba nacos+gateway网关实例)来看下怎么弄.只需动其中的两板斧: 1.pom引入sentinel适配器: <dependency> <groupId>com.alibaba.csp</groupId> <artifactId>sentinel-spring-cloud-gateway-a…
这里的feign依然是原来的feign,只不过将注册中心由eureka换成了nacos.服务提供方参见0.9.0.RELEASE版本的spring cloud alibaba nacos实例,消费方跟提供方一样,只需加入feign的相关内容即可.抡出三板斧: 1.pom加入feign: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.or…
gateway就是用来替换zuul的,功能都差不多,我们看下它怎么来跟nacos一起玩.老套路,三板斧: 1.pom: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xs…
简而言之,nacos与eureka的不同之处有三:后台老板.部署方式.功能.nacos是阿里的,eureka是奈飞的:nacos有自己的安装包,需要独立部署,eureka仅作为一个服务组件,引入jar包即可:nacos=eureka+config,它既是注册中心,也是配置中心. 如何使用nacos?先下载安装包(下载地址https://github.com/alibaba/nacos/releases),打开下载页 -> 点击目前最新版本1.1.3跳到下载页 -> 点击压缩包 -> 下载…
目录 Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探 1. Sentinel 是什么? 2. Sentinel 的特征: 3. Sentinel 的开源生态: 4. 简单使用 4.1 项目依赖pom.xml 4.2 定义资源 4.3 定义规则 4.4 Demo运行 Spring Cloud Alibaba | Sentinel: 分布式系统的流量防卫兵初探 Springboot: 2.1.6.RELEASE SpringCloud: Greenwic…
目录 Spring Cloud Alibaba | Sentinel: 服务限流基础篇 1. 简介 2. 定义资源 2.1 主流框架的默认适配 2.2 抛出异常的方式定义资源 2.3 返回布尔值方式定义资源 2.4 注解方式定义资源 2.5 异步调用支持 3. 规则的种类 3.1 流量控制规则 (FlowRule) 3.2 熔断降级规则 (DegradeRule) 3.3 系统保护规则 (SystemRule) 3.4 访问控制规则 (AuthorityRule) Spring Cloud Al…
目录 Spring Cloud Alibaba | Sentinel: 服务限流高级篇 1. 熔断降级 1.1 降级策略 2. 热点参数限流 2.1 项目依赖 2.2 热点参数规则 3. 系统自适应限流 3.1 背景 3.2 系统规则 3.3 原理 3.4 示例 4. 黑白名单控制 4.1 规则配置 4.2 示例 Spring Cloud Alibaba | Sentinel: 服务限流高级篇 Springboot: 2.1.6.RELEASE SpringCloud: Greenwich.SR…