-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Understanding eureka client server communication
Hopefully, at this point you have visited this page to understand how to setup the Eureka server.
The first step to interact with Eureka Server is to initialize the Eureka Client.If you are running in the AWS Cloud, you initialize the following way
DiscoveryManager.getInstance().initComponent(
new CloudInstanceConfig(),
new DefaultEurekaClientConfig());
If you are running in other data centers, you initialize the following way
DiscoveryManager.getInstance().initComponent(
new MyDataCenterInstanceConfig(),
new DefaultEurekaClientConfig());
Eureka client looks for eureka-client.properties as explained here.
This kickstarts the communication process between Eureka client and the server by registering the Eureka Client to the server. Eureka client first tries to talk to the Eureka Server in the same zone in the AWS cloud and if it cannot find the server it fails over to the other zones.
The Eureka client interacts with the server the following ways
Eureka client registers the information about the running instance to the Eureka server. In AWS Cloud, the information about an instance is available by accessing the URL _http://169.254.169.254/latest/metadata_.Registration happens on first heartbeat (after 30 seconds).
Eureka client needs to renew the lease by sending heartbeats every 30 seconds. The renews inform the Eureka server that the instance is still alive. If the server hasn't seen the renew for 90 seconds, it removes the instance out of it's registry. It is advisable not to change the renewal interval since the server uses that information to determine if there is a wide-spread problem with the client to server communication.
Eureka clients fetches the registry information from the server and caches it locally. After that, the clients use that information to find other services. This information is updated periodically (every 30 seconds) by getting the delta updates between the last fetch cycle and the current one. The delta holds information longer (for about 3 mins), hence the delta fetches may return the same instances again. The Eureka client automatically handles the duplicate information.
- Eureka at a glance
- Configuring Eureka
- Building Eureka Client and Server
- Running the Demo Application
- Deploying-Eureka-Servers-in-EC2
- Understanding Eureka Client/Server Communication
- Server Self Preservation Mode
- Eureka REST operations
- Understanding Eureka Peer to Peer communication
- Overriding Default Configurations
- FAQ