Sentinel

概述

Sentinel是Alibaba开源的一套用于服务容错的综合性解决方案。他以流量为切入点,从流量控制,熔断降级,系统负载保护等多个维度来保护服务的稳定性。

Sentinel核心分为两部分:

  1. 核心库:能够运行于所有Java运行时环境,同时对Dubbo/Spring Cloud等框架也有比较好的支持
  2. 控制台:基于Spring Boot开发,打包后可直接运行        

 下载Sentinel

https://github.com/alibaba/Sentinel/releases

 启动Sentinel

  •  在sentinel对应目录,打开命令行(cmd),启动运行sentinel

java -Dserver.port=8180 -Dcsp.sentinel.dashboard.server=localhost:8180 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.8.1.jar

 访问Sentinel

  •  localhost:8180

 登录Sentinel

  • 账号密码都是sentinel

Sentinel限流入门

  • 导入sentinel依赖

<dependency>
    <groupId>com.alibaba.cloud</groupId>
    <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
  • 配置bootstrap.yml文件

spring:
  cloud:
    sentinel:
      transport:
         dashboard: localhost:8180 # 指定sentinel控制台地址
  • 创建一个用于演示限流的Controller

@RestController
@RequestMapping("/provider")
public class ProviderSentinelController {
    @GetMapping("/sentinel01")
    public String doSentinel01(){
        return "sentinel 01 text.....";
    }
}
  •  设置指定接口接口流控

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值