You are on page 1of 4

/ Cloud Zone Log In / Sign Up

REFCARDZ GUIDES ZONES JOBS | AGILE BIG DATA CLOUD DATABASE DEVOPS INTEGRATION IOT JAVA MOBILE PERFORMANCE SECURITY WEB DEV

Let's be friends:

The Mystery of Eureka's Self-Preservation


Here, we examine a quick overview of how Eureka's self-preservation mode works as well as a couple of traps to avoid, depending on your network.

by Fahim Farook Jun. 14, 17 Cloud Zone

Like (3) Comment (0) Save Tweet

What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDB. Sign up and you'll receive instructions for how to get started!

When it comes to Eureka, self-preservation could be defined as "Eureka servers stop expiring clients from the registry when they do not receive heartbeats (from peers and client
microservices) beyond a certain threshold."

Let's take a look at the diagram below.

Suppose EC2 used to invoke EC4 after discovering it from a Eureka registry. Due to a network partition, EC4 and EC5 lost connectivity with the servers. Suppose as per our threshold
configuration, after two of the clients go down, Eureka servers enter self-preservation mode. From then onward, Eureka servers stop expiring the registry EC3 has gone down, but
it's still reflected in the registry.

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
The Rationale
Servers are not receiving heartbeats could be due to a poor network partition (i.e. does not necessarily mean the clients are down).

Even though the connectivity is lost between servers and a client, clients might have connectivity with each other

The Math
We can see the means of calculating the number of heartbeats per minute below. Netflix code assumes that the clients send heartbeats at 30-second intervals (default) for this
calculation.

Suppose:

The number of registered application instances at some point in time = N

The configured heartbeat threshold (to turn on self-preservation) = 0.85 (default)

Number of heartbeats expected from one client instance/min 2

Number of heartbeats expected from N instances/min 2*N

Minimum expected heartbeat threshold / min 2 * N * 0.85

Since N is a variable, 2 * N * 0.85 is calculated in every 15 minutes (default) by a scheduler.

Configurations (With Defaults)


eureka.instance.leaseRenewalIntervalInSeconds = 30 # hearbeat interval eureka.server.renewalPercentThreshold = 0.85 eureka.server.renewalThresholdUpdateIntervalMs = 15 * 60 * 1000 # 15 mins

Conclusions
Self-preservation incorrectly assumes few down microservice instances to be a poor network partition.

Self-preservation never expires, until and unless the down microservices are brought back (or the network glitch is resolved).

With self-preservation mode on, we cannot fine-tune the client heartbeat interval, since self-preservation assumes heartbeats are received at intervals of 30 seconds.

Unless these kinds of network glitches are common in your environment, self-preservation can be turned-off (even though most people recommend to keep it on).

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
What if you could learn how to use MongoDB directly from the experts, on your schedule, for free? We've put together the ultimate guide for learning MongoDB. Sign up and you'll receive instructions for how to get started!

Like This Article? Read More From DZone


Evicting Instances From Eureka Spring Cloud Sidecar

Building Cloud Native Apps With Spring - Part 7 Free DZone Refcard
Getting Started With OpenStack

DOWNLOAD

Topics: SPRING CLOUD , EUREKA , SELF-PRESERVATION , CLOUD , TUTORIAL

Like (3) Comment (0) Save Tweet

Published at DZone with permission of Fahim Farook. See the original article here.
Opinions expressed by DZone contributors are their own.

Cloud Partner Resources


Learn how to use MongoDB directly from the experts, for free. Sign up now to get started!
MongoDB

Introduction to Linkerd
Buoyant

The Challenges of Container Orchestration


Mesosphere

Get the Linkerd Kubernetes Service Mesh eBook


Buoyant

Free eBook: The guide to building & running data-driven applications


Mesosphere

Free report: How Mesos is enabling the adoption of containers and big data services
Mesosphere

open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com

You might also like