Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Eureka cluster to build a highly available service registry

Shulou Source: shulou.com Published: 2022-06-03 08:53:12 11月15日 Update

This article shows you how to use Eureka cluster to build a highly available service registry, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

In the actual development process, we may keep restarting the service. Because Eureka has its own protection mechanism, the service information will always exist in Eureka after the node goes offline. We can add some configurations to make the removal a little faster, of course, only in the development environment, not recommended in the production environment.

First, add two configurations to our eureka-server, which are to turn off the self-protection and cleanup intervals:

Eureka.server.enable-self-preservation=false# default 60000 millisecond eureka.server.eviction-interval-timer-in-ms=5000

Then configure the following in the specific client service:

Eureka.client.healthcheck.enabled=true# defaults to 30 seconds eureka.instance.lease-renewal-interval-in-seconds=5# defaults to 90 seconds eureka.instance.lease-expiration-duration-in-seconds=5

When eureka.client.healthcheck.enabled is used to turn on health check, you need to introduce the dependency of actuator into pom.xml, as shown below.

Org.springframework.bootspring-boot-starter-actuator

Where:

Eureka.instance.lease-renewal-interval-in-seconds represents the frequency at which the Eureka Client sends a heartbeat to the server side.

Eureka.instance.lease-expiration-duration-in-seconds indicates that the Eureka Server waits for the timeout of the next heartbeat after it received the last heartbeat from client, and removes the Instance if it does not receive the next heartbeat within this time.

For more Instance configuration information, please refer to the configuration class in the source code: org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.

For more Server configuration information, please refer to the configuration class in the source code: org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean.

The above content is how to use Eureka cluster to build a highly available service registry. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Configuration services information content more clusters skills time source code environment knowledge protection reference development concise healthy concise offline two code Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Shulou Tech Info MariaDB vpn Linux