最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

feign的ribbon超時(shí)配置和hystrix的超時(shí)配置說(shuō)明

 更新時(shí)間:2020年09月30日 09:09:09   作者:璀璨英雄  
這篇文章主要介紹了feign的ribbon超時(shí)配置和hystrix的超時(shí)配置說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

先看下我的配置:

ribbon:

MaxAutoRetries: 1 #最大重試次數(shù),當(dāng)Eureka中可以找到服務(wù),但是服務(wù)連不上時(shí)將會(huì)重試
MaxAutoRetriesNextServer: 1 #切換實(shí)例的重試次數(shù)
OkToRetryOnAllOperations: false # 對(duì)所有的操作請(qǐng)求都進(jìn)行重試,如果是get則可以,如果是post,put等操作沒(méi)有實(shí)現(xiàn)冪等的情況下是很危險(xiǎn)的,所以設(shè)置為false
ConnectTimeout: 1000 #請(qǐng)求連接的超時(shí)時(shí)間
ReadTimeout: 1800 #請(qǐng)求處理的超時(shí)時(shí)間

hystrix:

command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 3000
#如果配置ribbon的重試,hystrix的超時(shí)時(shí)間要大于ribbon的超時(shí)時(shí)間,ribbon才會(huì)重試
#hystrix的超時(shí)時(shí)間=(1 + MaxAutoRetries + MaxAutoRetriesNextServer) * ReadTimeout 比較好,具體看需求

Ribbon超時(shí)與Hystrix超時(shí)問(wèn)題,為了確保Ribbon重試的時(shí)候不被熔斷,我們就需要讓Hystrix的超時(shí)時(shí)間大于Ribbon的超時(shí)時(shí)間,否則Hystrix命令超時(shí)后,該命令直接熔斷,重試機(jī)制就沒(méi)有任何意義了。

從上面的配置來(lái)說(shuō),ribbon超時(shí)配置為1800,請(qǐng)求超時(shí)后,該實(shí)例會(huì)重試1次,更新實(shí)例會(huì)重試1次。

所以hystrix的超時(shí)時(shí)間要大于 (1 + MaxAutoRetries + MaxAutoRetriesNextServer) * ReadTimeout 比較好,具體看需求進(jìn)行配置。

Ribbon超時(shí)與Hystrix超時(shí)問(wèn)題,為了確保Ribbon重試的時(shí)候不被熔斷,我們就需要讓Hystrix的超時(shí)時(shí)間大于Ribbon的超時(shí)時(shí)間,否則Hystrix命令超時(shí)后,該命令直接熔斷,重試機(jī)制就沒(méi)有任何意義了。

補(bǔ)充知識(shí):Spring Cloud Feign 第一次調(diào)用超時(shí)(Read timed out)的解決辦法

feign-client在第一次調(diào)用微服務(wù)會(huì)出現(xiàn)Read timed out異常,提示的報(bào)錯(cuò)信息:

java.net.SocketTimeoutException: Read timed out

這是由于在調(diào)用其他微服務(wù)接口前,會(huì)去請(qǐng)求該微服務(wù)的相關(guān)信息(地址、端口等),并做一些初始化操作,由于默認(rèn)的懶加載特性,導(dǎo)致了在第一次調(diào)用時(shí),出現(xiàn)超時(shí)的情況,解決方法主要有兩種:

第一種辦法是設(shè)置超時(shí)時(shí)間,具體設(shè)置成多少,因項(xiàng)目而異,配置如下:

# 全局關(guān)閉Hystrix超時(shí),對(duì)所有微服務(wù)有效
hystrix.command.default.execution.timeout.enabled: false

# 關(guān)閉某一個(gè)微服務(wù)的超時(shí)
hystrix.command.<serviceName>.execution.timeout.enabled: false

# 全局設(shè)置超時(shí)時(shí)間為60秒
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 60000

# 設(shè)置某一個(gè)微服務(wù)的超時(shí)時(shí)間為60秒
hystrix.command.<serviceName>.execution.isolation.thread.timeoutInMilliseconds: 60000

# 設(shè)置ribbon超時(shí)時(shí)間
ribbon:
ReadTimeout: 20000
ConnectTimeout: 20000

第二種辦法,也是比較推薦的方式,配置ribbon立即加載,此處需要注意的是,光配置立即加載是不生效的,還要配置客戶端列表,配置如下,詳細(xì)配置請(qǐng)點(diǎn)擊

ribbon:
eager-load:
enabled: true
clients: distribution, material-product, outer-data

最后附上未開(kāi)啟立即加載時(shí),第一次調(diào)用打印的日志:

2019-05-27 18:05:33.819|INFO|1986|http-nio-18884-exec-2|clipcloud-configuration|3752c9412075144e|3752c9412075144e|false|com.migu.clipcloud.configuration.ConfigurationServiceApplication.test1-55|time:2019-05-27 18:05:33.819
2019-05-27 18:05:33.826|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.migu.clipcloud.services.client.FeignHeadConfiguration.lambda$requestInterceptor$2-51|add request header for feignclient, key:cookie,value:JSESSIONID.8250e395=node08z98wvylx12lwh89c6v09qk92.node0; screenResolution=1440x900; m=2258:cmFiYml0bXE6cmFiYml0bXE%253D
2019-05-27 18:05:33.828|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|org.springframework.context.support.AbstractApplicationContext.prepareRefresh-588|Refreshing SpringClientFactory-distribution: startup date [Mon May 27 18:05:33 CST 2019]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@203dd56b
2019-05-27 18:05:33.850|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.<init>-153|JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-05-27 18:05:33.864|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.config.ChainedDynamicProperty$ChainLink.checkAndFlip-115|Flipping property: distribution.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-05-27 18:05:33.865|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.util.concurrent.ShutdownEnabledTimer.<init>-58|Shutdown hook installed for: NFLoadBalancer-PingTimer-distribution
2019-05-27 18:05:33.866|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.loadbalancer.BaseLoadBalancer.initWithConfig-192|Client: distribution instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=distribution,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2019-05-27 18:05:33.884|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.loadbalancer.DynamicServerListLoadBalancer.enableAndInitLearnNewServersFeature-222|Using serverListUpdater PollingServerListUpdater
2019-05-27 18:05:33.886|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.config.ChainedDynamicProperty$ChainLink.checkAndFlip-115|Flipping property: distribution.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-05-27 18:05:33.887|INFO|1986|hystrix-distribution-1|clipcloud-configuration|3752c9412075144e|405382c2fc629614|false|com.netflix.loadbalancer.DynamicServerListLoadBalancer.restOfInit-150|DynamicServerListLoadBalancer for client distribution initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=distribution,current list of Servers=[192.168.26.103:18887],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone; Instance count:1; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;]
},Server stats: [[Server:192.168.26.103:18887; Zone:defaultZone; Total Requests:0; Successive connection failure:0; Total blackout seconds:0; Last connection made:Thu Jan 01 08:00:00 CST 1970; First connection made: Thu Jan 01 08:00:00 CST 1970; Active Connections:0; total failure count in last (1000) msecs:0; average resp time:0.0; 90 percentile resp time:0.0; 95 percentile resp time:0.0; min resp time:0.0; max resp time:0.0; stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@173441c2
2019-05-27 18:05:33.906|INFO|1986|http-nio-18884-exec-2|clipcloud-configuration|3752c9412075144e|3752c9412075144e|false|com.migu.clipcloud.configuration.ConfigurationServiceApplication.test1-57|time:2019-05-27 18:05:33.906
2019-05-27 18:05:34.888|INFO|1986|PollingServerListUpdater-0|clipcloud-configuration||||com.netflix.config.ChainedDynamicProperty$ChainLink.checkAndFlip-115|Flipping property: distribution.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647

以上這篇feign的ribbon超時(shí)配置和hystrix的超時(shí)配置說(shuō)明就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Springboot從配置文件properties讀取字符串亂碼的解決

    Springboot從配置文件properties讀取字符串亂碼的解決

    這篇文章主要介紹了Springboot從配置文件properties讀取字符串亂碼的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-02-02
  • Spring框架中Bean的各種加載方式詳解

    Spring框架中Bean的各種加載方式詳解

    這篇文章主要介紹了Spring框架中Bean的各種加載方式詳解,在Java中,"Bean"通常指的是由Spring框架管理的對(duì)象實(shí)例,Spring提供了多種方式來(lái)加載Bean,以滿足不同的需求和場(chǎng)景,需要的朋友可以參考下
    2023-08-08
  • java 基于maven多模塊合并打包部署的操作過(guò)程

    java 基于maven多模塊合并打包部署的操作過(guò)程

    這篇文章主要介紹了java 基于maven多模塊合并打包部署的操作過(guò)程,本文通過(guò)實(shí)例代碼圖文相結(jié)合給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2023-02-02
  • java可以作為第一門(mén)編程語(yǔ)言學(xué)習(xí)嗎

    java可以作為第一門(mén)編程語(yǔ)言學(xué)習(xí)嗎

    在本篇內(nèi)容里小編給JAVA零基礎(chǔ)的網(wǎng)友分享一篇關(guān)于java可以作為第一門(mén)編程語(yǔ)言學(xué)習(xí)嗎的文章,有興趣的朋友們可以參考下。
    2020-11-11
  • Java私有構(gòu)造函數(shù)作用原理解析

    Java私有構(gòu)造函數(shù)作用原理解析

    這篇文章主要介紹了Java私有構(gòu)造函數(shù)作用原理解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-12-12
  • SpringBoot全局異常處理方案分享

    SpringBoot全局異常處理方案分享

    這篇文章主要介紹了SpringBoot全局異常處理方案分享,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-05-05
  • 一文搞懂Java項(xiàng)目中枚舉的定義與使用

    一文搞懂Java項(xiàng)目中枚舉的定義與使用

    枚舉就是用enum修飾是一種Java特殊的類(lèi),枚舉是class、底層是繼承了java.lang.Enum類(lèi)的實(shí)體類(lèi)。本文將詳解枚舉的定義與使用,需要的可以參考一下
    2022-06-06
  • spring?cloud中Feign導(dǎo)入jar失敗的問(wèn)題及解決方案

    spring?cloud中Feign導(dǎo)入jar失敗的問(wèn)題及解決方案

    這篇文章主要介紹了spring?cloud中Feign導(dǎo)入jar失敗的問(wèn)題及解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • 移動(dòng)開(kāi)發(fā)Spring Boot外置tomcat教程及解決方法

    移動(dòng)開(kāi)發(fā)Spring Boot外置tomcat教程及解決方法

    這篇文章主要介紹了移動(dòng)開(kāi)發(fā)SpringBoot外置tomcat教程,需要的朋友可以參考下
    2017-11-11
  • 深入淺析Java注解框架

    深入淺析Java注解框架

    這篇文章主要介紹了深入淺析Java注解框架的相關(guān)資料,介紹的非常詳細(xì),具有參考價(jià)值,需要的朋友參考下吧
    2016-05-05

最新評(píng)論

金昌市| 金山区| 云和县| 新绛县| 个旧市| 哈巴河县| 隆德县| 巴彦淖尔市| 东丽区| 松江区| 昂仁县| 吉隆县| 南和县| 固镇县| 安顺市| 东乡族自治县| 镶黄旗| 淄博市| 湟源县| 汪清县| 蓬溪县| 灵山县| 宁强县| 博客| 无棣县| 玛多县| 海宁市| 漾濞| 灌南县| 子长县| 厦门市| 东明县| 三台县| 中江县| 同江市| 平阳县| 兴山县| 盐津县| 都兰县| 兴国县| 绩溪县|