Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build a highly available service registry by using Eureka cluster in SpringCloud

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces how SpringCloud uses Eureka cluster to build a highly available service registry. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

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.

So much for sharing about how SpringCloud uses Eureka clusters to build a highly available service registry. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report