Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Evicting Instances From Eureka

DZone's Guide to

Evicting Instances From Eureka

Spring Cloud Eureka's self-preservation tool is great for network problems, but it could keep your instances around when you don't want to. Fortunately, you can fix that.

· Cloud Zone
Free Resource

MongoDB Atlas is a database as a service that makes it easy to deploy, manage, and scale MongoDB. So you can focus on innovation, not operations. Brought to you in partnership with MongoDB.

Typically, when you are using Spring Cloud Eureka for service discovery and you shut down an instance that is registered with the server, that instance is removed from the registry. However, in some cases, that might not happen, and instead, the instance is just marked as being DOWN. If you look at your Eureka dashboard, you will see something like this.

Eureka Dashboard

Notice one of the RACES services is marked as down and the big red text above the table. You might run into this because, by default, if 85% of instances in Eureka are not sending heartbeats to the Eureka server, then the server will not evict them. When you see this, Eureka has entered what is called “self-preservation mode.”

The good news is you should not be alarmed by this. It is actually Eureka trying to be helpful and by not evicting instances that are not actually down. For example, there could be some network issues preventing instances from sending heartbeat information. Everything is still functioning correctly, so do you really want Eureka to start evicting instances? Probably not. With any luck, the network issues will resolve themselves and heartbeat information will eventually be received by the server.

If for whatever reason you want to turn off self-preservation mode, you can set eureka.server.enableSelfPreservation to false.

MongoDB Atlas is the best way to run MongoDB on AWS — highly secure by default, highly available, and fully elastic. Get started free. Brought to you in partnership with MongoDB.

Topics:
spring cloud ,eureka ,evicting instances ,cloud ,tutorial

Published at DZone with permission of Ryan Baxter, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}