spring cloud - Eureka Server Cache Refresh -


there 2 eureka servers (say es1 , es2) below configuration.

spring:   profiles: production  server:   port: 8761      eureka:   client:     registerwitheureka: true     fetchregistry: true     serviceurl:       defaultzone: http://${eureka.peer.hostname}:8761/eureka/ 

the synch works during release production when 1 eureka server(say es2) brought down other eureka server (es1) still maintains old cache information , when es2 started registers eureka clients de-registration of old clients doesn't happen results in stale information used ribbon load balancer.

for registering eureka clients below configuration used.

eureka:   instance:     metadatamap:       instanceid: ${service.contextpath}:${spring.application.instance_id:${random.value}}   client:     serviceurl:       defaultzone: http://localhost:8761/eureka/ 

why old instances not getting de-registered eureka server? because of have complete shutdown , restart of our infrastructure.

i guess see result of eureka's self preservation feature. in short, eureka server automatically stops expiring instance leases when notices has received less 80% of expected renewals during last minute. when es1 goes down, es2 doesn't receive heartbeats clients registered es1 anymore - activate self preservation mode.

to avoid situation, should configure clients both es1 and es2: client automatically switch es2 if es1 unavailable. this, list both addresses follows:

eureka:   client:     serviceurl:       defaultzone: http://es1:8761/eureka/,http://es2:8761/eureka/ 

you disable self protection feature - not expected configuration when in cluster - expect strange behavior :-(


Comments