Heartbeats, Self-Preservation & Failure Modes
Demystify Eureka Self-Preservation Mode, lease renewals, and how to prevent stale instance routing in production.
Every engineer working with Eureka will eventually see this terrifying red banner on the dashboard:
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.
What does this mean? Has your cluster crashed? Why is Eureka refusing to delete dead instances?
Welcome to Eureka Self-Preservation Mode.
01The Philosophy of Eureka: AP over CP
In terms of the CAP Theorem, Eureka is explicitly an AP (Available and Partition-Tolerant) system:
- It favors Availability over strict Consistency.
- Netflix realized that in distributed cloud networks, temporary network partitions happen frequently between datacenters.
The Network Partition Scenario:
Imagine Eureka Server runs in Datacenter A, and 20 instances of Payment Service run in Datacenter B:
- A fiber optic line between Datacenter A and B is cut.
- The 20 payment instances are 100% healthy and processing orders normally inside Datacenter B.
- BUT their 30-second heartbeats cannot reach Eureka Server in Datacenter A.
If Eureka acted like a strict CP system, it would assume all 20 payment instances died and evict them all from the registry. Now, no caller could reach payment instances, causing a 100% business outage.
Instead, Eureka enters Self-Preservation Mode:
- It realizes that renewals suddenly dropped below the expected renewal threshold (typically 85% of expected heartbeats).
- It concludes: "The problem is likely a network partition between me and the instances, not that all instances crashed simultaneously!"
- It freezes eviction and refuses to delete any instances from the registry, protecting availability.
Loading the rest of the lesson…