Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eureka never unregisters a service

I'm currently facing an issue where Eureka does not unregister a registered service. I've pulled the Eureka server example straight from git hub and made only one change, eureka.enableSelfPreservation = false. My application.yml looks like this:

server:   port: 8761 eureka:   enableSelfPreservation: false   client:     registerWithEureka: false fetchRegistry: false   server:     waitTimeInMsWhenSyncEmpty: 0 

I've read that if 85% of the registered services stop delivering heartbeats within 15 minutes, Eureka assumes the issue is network related and does not de-register the services that are not responding. In my case I have only one service running, so I disabled self-preservation mode. I am abruptly killing the process and Eureka leaves the service registered for what seems like an indefinite amount of time.

My client's application.yml looks like this:

eureka:   instance:     leaseRenewalIntervalInSeconds: 3   client:     healthcheck:       enabled: true     serviceUrl:       defaultZone: http://localhost:8761/eureka/   appInfo:     replicate:       interval: 3     initial:       replicate:         time: 3 spring:   rabbitmq:     addresses: ${vcap.services.${PREFIX:}rabbitmq.credentials.uri:amqp://${RABBITMQ_HOST:localhost}:${RABBITMQ_PORT:5672}} 

My goal is to create a demo where Eureka quickly detects the service is no longer running and another service that is started can quickly register itself.

As of now, once the eureka client is started, it registers in 3 seconds. It just never un-registers when the service is abruptly terminated. After I kill the service, the Eureka dashboard reads:

EMERGENCY! EUREKA MAY BE INCORRECTLY CLAIMING INSTANCES ARE UP WHEN THEY'RE NOT. RENEWALS ARE LESSER THAN THRESHOLD AND HENCE THE INSTANCES ARE NOT BEING EXPIRED JUST TO BE SAFE.

How can I prevent this behavior?

like image 335
lp1776 Avatar asked Sep 16 '15 18:09

lp1776


People also ask

How do you check if the service is registered in Eureka?

Hit the URL http://localhost:8761/ in your web browser and you can see the Eureka Client application is registered with Eureka Server. Now hit the URL http://localhost:8080/ in your web browser and see the Rest Endpoint output.

What is a Eureka service?

Eureka Server is an application that holds the information about all client-service applications. Every Micro service will register into the Eureka server and Eureka server knows all the client applications running on each port and IP address. Eureka Server is also known as Discovery Server.

Why is Eureka Service registered?

You will set up a Netflix Eureka service registry and then build a client that both registers itself with the registry and uses it to resolve its own host. A service registry is useful because it enables client-side load-balancing and decouples service providers from consumers without the need for DNS.

Is Netflix Eureka deprecated?

According to the Eureka wiki (https://github.com/Netflix/eureka/wiki), the Eureka 2.0 has been discontinued. The open source work on eureka 2.0 has been discontinued. The code base and artifacts that were released as part of the existing repository of work on the 2. x branch is considered use at your own risk.


2 Answers

I realized that self preservation mode was never actually being disabled. It turns out the actual property is

eureka.server.enableSelfPreservation=false 

(See DefaultEurekaServerConfig Code), which I haven't found documented anywhere. This resolved my issue.

like image 178
lp1776 Avatar answered Dec 17 '22 22:12

lp1776


I made service de-registration work by setting the below values

Eureka server application.yml

eureka:   server:     enableSelfPreservation: false 

Service application.yml

eureka:   instance:     leaseRenewalIntervalInSeconds: 1     leaseExpirationDurationInSeconds: 2 

The full example is here https://github.com/ExampleDriven/spring-cloud-eureka-example

like image 22
Peter Szanto Avatar answered Dec 17 '22 22:12

Peter Szanto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!