Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eureka's self-preservation mode never recovers

I'm currently facing an issue where Eureka never clears out service instances that have become stale because a VM went down unexpectedly. Understandably, Eureka's self-preservation mode kicked in because there was a large drop (below the threshold) in service renewals/heartbeat requests. However, 15+ hours later the dead instances are still registered in Eureka. This is a major problem as service requests continue to be directed to the dead instances only to return errors.

My hope was that the threshold is continuously adjusted and after some period of time, Eureka's threshold would be at a new norm level and self-preservation mode would be reset. We are using Eureka in mirrored setup and our configurations are not very complex.

Our setup:

Eureka via spring-boot-starter-parent 1.2.5.RELEASE

eureka:
  dashboard:
    path: services
    enabled: false
  instance:
    hostname: localhost
    leaseRenewalIntervalInSeconds: 3
    metadataMap:
      managementPath: /admin
      instanceId: discoveryPrimary
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
  server:
    waitTimeInMsWhenSyncEmpty: 0

Is it possible to adjust Eureka configurations to reset the self-preservation mode (where it stops clearing instances) and allow it to clear service registries if the services are dead for 5+ minutes?

like image 626
restwzeasy Avatar asked Oct 15 '15 14:10

restwzeasy


People also ask

What is Eureka self preservation mode?

Self-preservation is a feature where Eureka servers stop expiring the client instances from the registry when they do not receive heartbeats (from peers and client microservices) beyond a certain threshold.

What is the default Eureka lease renewal time?

lease-renewal-interval-in-seconds indicates the interval of heartbeats that the client sends to the server. The default value is 30 seconds which means that the client will send one heartbeat every 30 seconds.

What is leaseRenewalIntervalInSeconds?

leaseRenewalIntervalInSeconds defines how many renews sent to server per minute, but it will multiply a factor eureka. server.

What is default zone in Eureka?

eureka: client: serviceUrl: defaultZone: http://localhost:8761/eureka/ In the preceding example, "defaultZone" is a magic string fallback value that provides the service URL for any client that does not express a preference (in other words, it is a useful default).


1 Answers

If you are having only a few instances of your services, everytime any of them fail, the self preservation will kick in because on default the renewalPercentThreshold is 0.85.

So if only 84% of your instances renewed their lease eureka "turns on" self preservation.

This means if you have 3 instances and one fails, only 66% percent of them renewed their licences so none will get deregistered. You can tune renewalPercentThreshold in the server properties to suite your deployment.

eureka:
  server:
    renewalPercentThreshold: 0.49

With this, if you have 2 instances and 1 fails you are still good.

like image 90
Ákos Ratku Avatar answered Sep 30 '22 09:09

Ákos Ratku