Feignとzulの問題要約の使用
6113 ワード
1.エラーLoad balancer does not have available server for client:CONTENT-SERVICE解決方法
私もこの問題を考えて、テストはいつも私にバグを出して、そしてフロントエンドはずっと私に要求が成功しないことを聞いて、第1回と第2回はすべてこの問題が発生する可能性があって、それからこの問題がなくて、インターネットで問題を見て、
Spring Cloudを参照して、Feign/Ribbonの最初のリクエストに失敗した問題をどのように解決しますか?
解決策は最後のものであり、呼び出し元サービスymlに次の構成を追加する(A呼び出しB、A構成):ribbon:
eager-load:
enabled: true
clients: content-service, product-service
起動時ログ:2019-06-02 11:24:26.874 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client content-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=content-service,current list of Servers=[169.254.71.137:9021],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:169.254.71.137:9021; 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@153409b8
2019-06-02 11:24:26.914 INFO 15264 --- [ main] org.springframework.context.annotation.AnnotationConfigApplicationContext : Refreshing SpringClientFactory-product-service: startup date [Sun Jun 02 11:24:26 CST 2019]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@a10c1b5
2019-06-02 11:24:26.952 INFO 15264 --- [ main] org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-06-02 11:24:27.012 INFO 15264 --- [ main] com.netflix.config.ChainedDynamicProperty : Flipping property: product-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-02 11:24:27.020 INFO 15264 --- [ main] com.netflix.util.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-product-service
2019-06-02 11:24:27.021 INFO 15264 --- [ main] com.netflix.loadbalancer.BaseLoadBalancer : Client: product-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=product-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2019-06-02 11:24:27.022 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2019-06-02 11:24:27.024 INFO 15264 --- [ main] com.netflix.config.ChainedDynamicProperty : Flipping property: product-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-02 11:24:27.025 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client product-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=product-service,current list of Servers=[169.254.71.137:9011],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:169.254.71.137:9011; 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@63ad5fe7
上のログはAがBを見つけたことを説明して、問題は解決しました
2.第2の問題はzulとfeignで発生します.Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out
at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
at rx.observables.BlockingObservable.single(BlockingObservable.java:341)
at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:112)
... 131 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
タイムアウトの問題、問題はどこですか?ヒューズタイムアウトのデフォルト時間は1 sである可能性があります.初めてなので、feignはclientを見つけ、次にリンクを確立し、最後にデータを取得して返します.そのため、時間は1 sを超え、上記のタイムアウトを報告しました.解決策は以下の通りです.spring:
#
cloud:
loadbalancer:
retry:
enabled: true
ribbon:
#
eager-load:
enabled: true
clients: content-service, product-service
# ( )
ReadTimeout: 8000
ConnectTimeout: 8000
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000
ribbon:
eager-load:
enabled: true
clients: content-service, product-service
2019-06-02 11:24:26.874 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client content-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=content-service,current list of Servers=[169.254.71.137:9021],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:169.254.71.137:9021; 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@153409b8
2019-06-02 11:24:26.914 INFO 15264 --- [ main] org.springframework.context.annotation.AnnotationConfigApplicationContext : Refreshing SpringClientFactory-product-service: startup date [Sun Jun 02 11:24:26 CST 2019]; parent: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@a10c1b5
2019-06-02 11:24:26.952 INFO 15264 --- [ main] org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2019-06-02 11:24:27.012 INFO 15264 --- [ main] com.netflix.config.ChainedDynamicProperty : Flipping property: product-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-02 11:24:27.020 INFO 15264 --- [ main] com.netflix.util.concurrent.ShutdownEnabledTimer : Shutdown hook installed for: NFLoadBalancer-PingTimer-product-service
2019-06-02 11:24:27.021 INFO 15264 --- [ main] com.netflix.loadbalancer.BaseLoadBalancer : Client: product-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=product-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2019-06-02 11:24:27.022 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : Using serverListUpdater PollingServerListUpdater
2019-06-02 11:24:27.024 INFO 15264 --- [ main] com.netflix.config.ChainedDynamicProperty : Flipping property: product-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2019-06-02 11:24:27.025 INFO 15264 --- [ main] com.netflix.loadbalancer.DynamicServerListLoadBalancer : DynamicServerListLoadBalancer for client product-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=product-service,current list of Servers=[169.254.71.137:9011],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:169.254.71.137:9011; 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@63ad5fe7
Caused by: java.lang.RuntimeException: java.net.SocketTimeoutException: Read timed out
at rx.exceptions.Exceptions.propagate(Exceptions.java:58)
at rx.observables.BlockingObservable.blockForSingle(BlockingObservable.java:464)
at rx.observables.BlockingObservable.single(BlockingObservable.java:341)
at com.netflix.client.AbstractLoadBalancerAwareClient.executeWithLoadBalancer(AbstractLoadBalancerAwareClient.java:112)
... 131 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
spring:
#
cloud:
loadbalancer:
retry:
enabled: true
ribbon:
#
eager-load:
enabled: true
clients: content-service, product-service
# ( )
ReadTimeout: 8000
ConnectTimeout: 8000
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 10000