欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

微服務(wù)熔斷限流Hystrix之Dashboard

簡介

Hystrix Dashboard是一款針對Hystrix進行實時監(jiān)控的工具,通過Hystrix Dashboard可以直觀地看到各Hystrix Command的請求響應(yīng)時間,請求成功率等數(shù)據(jù)。

創(chuàng)新互聯(lián)服務(wù)項目包括棲霞網(wǎng)站建設(shè)、棲霞網(wǎng)站制作、棲霞網(wǎng)頁制作以及棲霞網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,棲霞網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到棲霞省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

快速上手

工程說明

工程名端口作用
eureka-server 8761 注冊中心
service-hi 8762 服務(wù)提供者
service-consumer 8763 服務(wù)消費者

核心代碼

eureka-server 工程
pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
application.yml
server:
  port: 8761
eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${eureka.instance.hostname}:/${server.port}/eureka/
spring:
  application:
    name: eureka-server
啟動類
@SpringBootApplication
@EnableEurekaServer
public class EurekaServerApplication {

    public static void main(String[] args) {
        SpringApplication.run( EurekaServerApplication.class, args );
    }

}

service-hi 工程

pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
application.yml
server:
  port: 8762

spring:
  application:
    name: service-hi
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
HelloController
@RestController
public class HelloController {

    @GetMapping("/hi")
    public String hi() {
        return "hello ~";
    }

    @GetMapping("/hey")
    public String hey() {
        return "hey ~";
    }

    @GetMapping("/oh")
    public String oh() {
        return "ah ~";
    }

    @GetMapping("/ah")
    public String ah() {
        //模擬接口1/3的概率超時
        Random rand = new Random();
        int randomNum = rand.nextInt(3) + 1;
        if (3 == randomNum) {
            try {
                Thread.sleep( 3000 );
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return "來了老弟~";
    }

}
啟動類
@SpringBootApplication
@EnableEurekaClient
public class ServiceHiApplication {

    public static void main(String[] args) {
        SpringApplication.run( ServiceHiApplication.class, args );
    }

}

service-consumer 工程

pom.xml
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
application.yml
server:
  port: 8763

  tomcat:
    uri-encoding: UTF-8
    max-threads: 1000
    max-connections: 20000

spring:
  application:
    name: service-consumer
eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/

management:
  endpoints:
    web:
      exposure:
        include: "*"
      cors:
        allowed-origins: "*"
        allowed-methods: "*"
HelloService
@Service
public class HelloService {

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 簡單用法
     */
    @HystrixCommand
    public String hiService() {
        return restTemplate.getForObject("http://SERVICE-HI/hi" , String.class);
    }

    /**
     * 定制超時
     */
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000") })
    public String heyService() {
        return restTemplate.getForObject("http://SERVICE-HI/hey" , String.class);
    }

    /**
     * 定制降級方法
     */
    @HystrixCommand(fallbackMethod = "getFallback")
    public String ahService() {
        return restTemplate.getForObject("http://SERVICE-HI/ah" , String.class);
    }

    /**
     * 定制線程池隔離策略
     */
    @HystrixCommand(fallbackMethod = "getFallback",
            threadPoolKey = "studentServiceThreadPool",
            threadPoolProperties = {
                    @HystrixProperty(name="coreSize", value="30"),
                    @HystrixProperty(name="maxQueueSize", value="50")
            }
    )
    public String ohService() {
        return restTemplate.getForObject("http://SERVICE-HI/oh" , String.class);
    }

    public String getFallback() {
        return "Oh , sorry , error !";
    }

}
HelloController
@RestController
public class HelloController {

    @Autowired
    private HelloService helloService;

    @GetMapping("/hi")
    public String hi() {
        return helloService.hiService();
    }

    @GetMapping("/hey")
    public String hey() {
        return helloService.heyService();
    }

    @GetMapping("/oh")
    public String oh() {
        return helloService.ohService();
    }

    @GetMapping("/ah")
    public String ah() {
        return helloService.ahService();
    }

}
啟動類
@SpringBootApplication
@EnableEurekaClient
@EnableHystrixDashboard
@EnableHystrix
@EnableCircuitBreaker
public class ServiceConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run( ServiceConsumerApplication.class, args );
    }

    @LoadBalanced
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

}

Hystrix Dashboard 的使用

JSON格式監(jiān)控信息

先訪問http://localhost:8762/hi
再打開http://localhost:8763/actuator/hystrix.stream,可以看到一些具體的數(shù)據(jù):

微服務(wù)熔斷限流Hystrix之Dashboard

Hystrix儀表盤監(jiān)控信息

單純的查看json數(shù)據(jù),很難分析出結(jié)果,所以,要在Hystrix儀表盤中來查看這一段json,在hystrix儀表盤中輸入監(jiān)控地址進行監(jiān)控:
打開儀表盤地址:http://localhost:8762/hystrix

微服務(wù)熔斷限流Hystrix之Dashboard

在界面依次輸入:http://localhost:8763/actuator/hystrix.stream 、2000 、service-consumer;點確定。

微服務(wù)熔斷限流Hystrix之Dashboard

Hystrix儀表盤指標(biāo)含義

微服務(wù)熔斷限流Hystrix之Dashboard

測試

編一個測試腳本curl.sh

while true;
do
curl "http://localhost:8763/hi";
curl "http://localhost:8763/hey";
curl "http://localhost:8763/oh";
curl "http://localhost:8763/ah";
done

執(zhí)行測試腳本,查看Hystrix儀表盤:

微服務(wù)熔斷限流Hystrix之Dashboard

可以看出 ahService 因為模擬了1/3的概率超時,所以監(jiān)控中呈現(xiàn)了30%左右的錯誤百分比。

源碼

https://github.com/gf-huanchupk/SpringCloudLearning/tree/master/chapter17

歡迎關(guān)注我的公眾號《程序員果果》,關(guān)注有驚喜~~
微服務(wù)熔斷限流Hystrix之Dashboard

本文名稱:微服務(wù)熔斷限流Hystrix之Dashboard
分享路徑:http://aaarwkj.com/article12/gojjdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、企業(yè)建站網(wǎng)站內(nèi)鏈、建站公司網(wǎng)站設(shè)計、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站制作
国产精品久久中文字幕亚洲| 99久久婷婷免费国产综合精品| 免费在线观看做性小视频| 国产成人一区二区二区三区| 日韩精品欧美精品一区二区| 天天日天天天干夜夜操| 国产深夜福利在线观看| 青青草原成年人免费看| 婷婷中文字幕在线视频| 久国产精品韩国三级视频| 亚洲一区二区三区精品电影网| 国产欧美日韩精品久久久久久| 日韩精品在线另类亚洲| 亚洲精品色播一区二区| 1区2区3区精品视频| 午夜视频在线观看91| 日韩成人三级一区二区| 97热久久精品中文字幕一区| 国产精品欧美久久久久久| 午夜国产激情福利网站| 久国产精品久久久极品| 色哟哟视频在线免费观看| 亚洲国产日韩欧美视频二区| 丝袜美腿一区在线播放| 亚洲少妇精品视频在线 | 日韩无砖区2021不卡| 日韩欧美黄色三级视频| 97乱碰视频在线观看| 尤物视频网站在线观看| 四虎精品国产一区二区三区| 国产精品麻豆色哟哟av| 日韩欧美亚洲一区二区三区| 亚洲欧美日韩一区91| 九九热这里面只有精品| 国产高清学生三级一区二区| 嫩草网站国产精品一区二| 不卡一区二区福利日本| 一本色道av久久精品+| 国产精品一区在线播放| 亚洲午夜精品毛片成人| 亚洲av成人永久网站一区|