Background: Because Eureka has a self-protection mechanism, Eureka does not remove the service registration when the service in its registry is shut down due to network or other reasons, but waits for it to be repaired. This is an implementation of AP. In order to make it have accurate CP health check, unhealthy nodes can be eliminated.
Server side: eureka.server.enable-self-preservation// (set to false, turn off self-protection main)
eureka.server.eviction-interval-timer-in-ms// Clean interval (in milliseconds, default is 60*1000)The client side: eureka.client.healthcheck.enabled = true// Enable health check (requires spring-boot-starter-actuator dependencies)
eureka.instance.lease-renewal-interval-in-seconds =10// Lease update interval (default 30 seconds)
eureka.instance.lease-expiration-duration-in-seconds =30// Lease expiration time (default 90 seconds)Copy the code
Example:
serverEnd configuration: Eureka:server:
enableSelfPreservation: false
evictionIntervalTimerInMs: 4000
clientConfiguration: eureka: instance: leaseRenewalIntervalInSeconds:10
leaseExpirationDurationInSeconds: 30Copy the code
Note: Changing the Eureka update frequency will break the server’s self-protection feature