【发布时间】:2017-11-22 08:28:21
【问题描述】:
我有一个场景,Spring Boot Zuul 作为外部网关,Eureka 作为服务发现,所有这些都在 Kubernetes 中运行。
问题是,我想保证我的服务的可用性,所以当我的服务实例出现故障时,我希望 Zuul 通过 Eureka 重试调用其他实例之一。
我尝试通过关注Ryan Baxter's post 来做到这一点。 另外,我尝试按照here 的提示进行操作。
问题是无论我做什么,看起来 Zuul 都没有重试拨打电话。当我删除我的一个实例时,它会一直为我返回这个实例的超时,直到 Eureka 地址同步。
我的 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
我的服务使用的是 Camden SR7(我也试过 SR6):
"org.springframework.cloud:spring-cloud-dependencies:Camden.SR7"
还有弹簧重试:
org.springframework.retry:spring-retry:1.1.5.RELEASE
我的应用程序类如下所示:
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
@EnableRetry
public class MyZuulApplication
编辑:
通过邮递员,它带来了
{
"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; [ ... ]
【问题讨论】:
-
你得到的确切例外是什么?
-
我编辑了原始帖子并提供了更多信息
标签: spring-boot kubernetes netflix-eureka netflix-zuul