zoukankan      html  css  js  c++  java
  • spring cloud 实践坑点记录

    用spring cloud 微服务框架有一段时间了有一些坑点在这里给大家记录一下希望大家用得着

    1、当我们使用聚合性能监控的时候,我们采用 rabbitmq作为消息中间件来收集性能信息最后在使用TurbineStream将信息进行聚合

      这个工具聚合是根据“应用名+方法名”进行求和汇总的

      如下代码:

      

    @HystrixCommand(commandProperties = {
                @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
                        @HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
        @GetMapping("/testpro3")
        public int getStringtest2(){
    
            //throw new Exception("ddd");
            return 1;
        }

      这里的聚合就是“应用名+getStringtest2”

      

      这样的话就会存在一个问题在不同的两个类都是被@RestController标记并且都对外发布接口的url不同功能也不同

      如下:

      

    @RestController
    public class testRest1 {
        @HystrixCommand(commandProperties = {
                @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
                        @HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
        @GetMapping("/testpro3")
        public int getStringtest2(){
    
            //throw new Exception("ddd");
            return 1;
        }
    }
    @RestController
    public class testRest1 {
        @HystrixCommand(commandProperties = {
                @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "20000") }, threadPoolProperties = {
                        @HystrixProperty(name = "coreSize", value = "64") }, threadPoolKey = "test1")
        @GetMapping("/testpro4")
        public int getStringtest2(){
    
            //throw new Exception("ddd");
            return 1;
        }
    }

      假如像上面的代码在一个工程里面就会吧这两个方法的性能进行聚合,可能我们在项目中很少出现这种情况但是 墨菲定律 有可能发生的事情就一定会发生

    2、配置文件服务器刷新坑点

      当我们的spring boot应用使用配置中心进行配置加载的时候,当我们的配置文件更新的时候去刷新通知我们的URL通常是这样的

      10.10.12.51:8888/bus/refresh?destination=spring-cloud-demo:8082进行post请求

      上面的url是没问题的但是我们可能会看到EUREKA注册中心对应用名全是大写的 如下

      

      这样就会给我们一个误导是不是用全部是大写的应用名也可以啊??向下面这样

      

    10.10.12.51:8888/bus/refresh?destination=SPRING-CLOUD-DEMO:8082

      经过测试这样是不行的,所以请大家注意

    服务监控信息到底是“主动推送”还是“被动扫描”???

    spring boot +RabbitMQ +InfluxDB+Grafara监控实践

  • 相关阅读:
    一、CentOS 7安装部署GitLab服务器

    四、指定Nginx启动用户
    三、Nginx支持php
    二、Nginx多站点配置(参考宝塔的)分析
    一、Nginx多站点配置
    一、PHP和Apache实现多用户自助建站
    Flask+uwsgi+Nginx+Ubuntu部署
    flask 上传头像
    flask 分页
  • 原文地址:https://www.cnblogs.com/zhyg/p/9450300.html
Copyright © 2011-2022 走看看