2017-06-20 9 views
0

私は、外部ゲートウェイとしてSpring Boot ZuulとService DiscoveryとしてEurekaというシナリオを持っていますが、これらはすべてKubernetesで動作しています。Zuulの再試行設定がEurekaと連携していません

サービスの可用性を保証したいので、サービスのインスタンスがダウンすると、私はZuulがユーレカを通じて他のインスタンスの1つを呼び出すことを再試行することを期待しています。

これを次のようにしてみました。Ryan Baxter's post さらに、私はhereのヒントに従おうとしました。

問題は、私が作るものは、ズールが電話をやり直していないように見えるということです。インスタンスの1つを削除すると、ユーレカのアドレスが同期するまで、このインスタンスのタイムアウトが返され続けます。

マイapplication.yamlは次のようになります。

spring: 
    cloud: 
    loadbalancer: 
     retry: 
     enabled: true 

zuul: 
    stripPrefix: true 
    ignoredServices: '*' 
    routes: 
    my-service: 
     path: /my-service/** 
     serviceId: my-service-api 
    retryable: true 

my-service: 
    ribbon: 
    maxAutoRetries: 3 
    MaxAutoRetriesNextServer: 3 
    OkToRetryOnAllOperations: true 
    ReadTimeout: 5000 
    ConnectTimeout: 3000 

私のサービスは(私もSR6を試してみました)カムデンSR7を使用している:

"org.springframework.cloud:spring-cloud-dependencies:Camden.SR7" 

そしてまた春のリトライ:

org.springframework.retry:spring-retry:1.1.5.RELEASE 

私のアプリケーションクラスは次のようになります:

@SpringBootApplication 
@EnableEurekaClient 
@EnableZuulProxy 
@EnableRetry 
public class MyZuulApplication 

EDIT:

はポストマンを介して取得作り、それが

{ 
    "timestamp": 1497959364819, 
    "status": 500, 
    "error": "Internal Server Error", 
    "exception": "com.netflix.zuul.exception.ZuulException", 
    "message": "TIMEOUT" 
}. 

がZuulログを見てみるともたらし、それは{"level":"WARN","logger_name":"org.springframework.cloud.netflix.zuul.filters.post.SendErrorFilter","appName":...,"message":"Error during filtering","stack_trace":"com.netflix.zuul.exception.ZuulException: Forwarding error [... Stack Trace ...] Caused by: com.netflix.hystrix.exception.HystrixRuntimeException: my-service-api timed-out and no fallback available [... Stack Trace ...] Caused by: java.util.concurrent.TimeoutException: null

私が見つけたもう一つの興味深いログを印刷しました

{"level":"INFO" [...] current list of Servers=[ip_address1:port, ip_address2:port, ip_address3:port],Load balancer stats=Zone stats: {defaultzone=[Zone:[ ... ]; Instance count:3; Active connections count: 0; Circuit breaker tripped count: 0; Active connections per server: 0.0;] 
},Server stats: [[Server:ip_address1:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ] 
, [Server:ip_address2:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ] 
, [Server:ip_address3:port; [ ... ] Total Requests:0; Successive connection failure:0; Total blackout seconds:0; [ ... ] 
+0

正確な例外は何ですか? –

+0

元の投稿をさらに編集しました –

答えて

0

問題はHystrixによって発生しているようですタイムアウト。 HystrixCommandのデフォルトタイムアウトは1000msで、リボンがhttp要求を再試行するのに十分ではありません。 ヒステリシスのタイムアウトを次のように増やしてください。

hystrix: 
    command: 
    default: 
     execution: 
     isolation: 
      thread: 
      timeoutInMilliseconds: 20000 

hystrixコマンドのタイムアウトが20秒に増加します。それが機能する場合は、ご使​​用の環境の上記の値を調整してください。読み取りと接続のタイムアウトにはかなり大きなタイムアウト値を使用しています。したがって、必要に応じてhystrixタイムアウトを使用してこれらの値を調整する必要があります。

+0

助けてくれてありがとう。私は後でそれを試し、次に私はここに投稿します。 –

+0

私はテストし、それは魅力のように働いた。私はタイムアウトを私にとってより意味のあるものに調整します。ありがとうございました! –

関連する問題