首页 文章

Eureka检测服务状态

提问于
浏览
2

Context

我们使用Spring Cloud Netflix和Eureka作为服务发现,使用Zuul代理服务并对它们进行负载均衡 .

微服务使用NodeJS实现,并使用NPM模块eureka-js-client在Eureka注册,中间有一个自定义层,用于处理配置和所有微服务通用的内容 .


Problem

问题是Eureka无法识别是否有一项服务出现故障 . 这是一个问题,因为我们正在使用具有自动部署的开发基础架构,每次重新部署并重新启动不同端口上的微服务而无需重新启动Eureka(和Zuul) .

因此,过了一段时间,我们有一个微服务的十个或更多实例,其中只有一个上升,但所有被认为是beeing UP .


Solution Approach

  • 我尝试在客户端上设置 heartbeatInterval 较小,但这没有帮助 .

  • 我尝试在服务器上设置 renewalThresholdUpdateIntervalMs 较小,但这也无济于事 .

  • 更多令人沮丧,无助的 property 尝试......


Question

如何配置Eureka以驱逐实例或将状态设置为在合理时间内(不是30分钟左右)不发送心跳的实例的 DOWN


Code Snippets

服务器本身不包含可提及的代码(只需几个注释即可使用Spring Cloud Starter启动Eureka服务器) .

Eureka服务器的配置(我删除了所有非工作尝试):

server:
  port: 8761

spring:
  cloud:
    client:
      hostname: localhost

eureka:
  instance:
    address: 127.0.0.1
    hostname: ${spring.cloud.client.hostname}

发送到服务器的客户端配置(使用eureka-js-client):

{
    instance : {
        instanceId : `${CONFIG.instance.address}:${CONFIG.instance.name}:${CONFIG.instance.port}`,
        app : CONFIG.instance.name,
        hostName : CONFIG.instance.host,
        ipAddr : CONFIG.instance.address,
        port : {
            '$' : CONFIG.instance.port,
            '@enabled' : true
        },
        homePageUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/`,
        statusPageUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/info`,
        healthCheckUrl : `http://${CONFIG.instance.host}:${CONFIG.instance.port}/health`,
        vipAddress : CONFIG.instance.name,
        secureVipAddress : CONFIG.instance.name,
        dataCenterInfo : {
            '@class' : 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
            name : 'MyOwn'
        }
    },
    eureka : {
        host : CONFIG.eureka.host,
        port : CONFIG.eureka.port,
        servicePath : CONFIG.eureka.servicePath || '/eureka/apps/',
        healthCheckInterval : 5000
    }
}

1 回答

  • 2

    过了一段时间,我们有一个微服务的十个或更多实例,其中只有一个启动,但所有都被认为是上升 .

    尤里卡有一种“自我保护”模式 . 如果少于85%的实例心跳正在注册,则不会驱逐任何实例 . 您应该能够在尤里卡仪表板上看到警告 .

相关问题