Spring Cloud全解析:熔断之Hystrix配置参数

2024-09-04  本文已影响0人  墨线宝

Hystrix配置参数

@HystrixCommand(groupKey="UserGroup", commandKey = "GetUserByIdCommand",
                commandProperties = {
                    @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "100"),//指定多久超时,单位毫秒。超时进fallback
                    @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"),//判断熔断的最少请求数,默认是10;只有在一个统计窗口内处理的请求数量达到这个阈值,才会进行熔断与否的判断
                    @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "10"),//判断熔断的阈值,默认值50,表示在一个统计窗口内有50%的请求处理失败,会触发熔断
                },
                threadPoolProperties = {
                        @HystrixProperty(name = "coreSize", value = "30"),
                        @HystrixProperty(name = "maxQueueSize", value = "101"),
                        @HystrixProperty(name = "keepAliveTimeMinutes", value = "2"),
                        @HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"),
                        @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),
                        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440")
        })

commandProperties参数

HystrixCommandProperties

如果配置中同时包含Ribbon和Hystrix的超时配置,需要确保Hystrix超时配置长于Ribbon的超时配置

threadPoolProperties配置

线程池配置

HystrixThreadPoolProperties

https://zhhll.icu/2021/框架/微服务/springcloud/熔断/Hystrix断路器/3.Hystrix配置参数/

上一篇 下一篇

猜你喜欢

热点阅读