Spring Cloud Eureka Configuration

Source: Internet
Author: User

Instance Name configuration

in the native implementation of the Netflix Eureka, the instance name takes the hostname as the default, so that multiple identical instances cannot be started on the same host, so in the spring Cloud Eureka configuration, multiple instances are launched for the same host. The following rules apply:

Eureka.instance.instanceid=${spring.application.name}:${random.  int}

Using the application name plus the random number to distinguish between different instances, so that the same host, do not specify a port can easily start multiple instances of the effect.

Endpoint Configuration

in Instanceinfo, we can see some of the URL configuration information, such as Homepageurl, Statuspageurl, Healthcheckurl, they represent the application page status URL, the status of the URL, Health Check URL. The URL for the Status page and health check uses the/INFO endpoint and/health endpoint provided by the Spring-boot-actuator module by default in spring Cloud Eureka.

In most cases, we do not need to modify the configuration of these URLs, but if Context-path is set, then all Spring-boot-actuator modules will have a prefix added to the monitoring endpoint. So we need to make the following changes:

management.context-path=/helloeureka.instance.statusPageUrlPath=${management.context-path}/  Infoeureka.instance.healthCheckUrlPath=${management.context-path}/health

Health Check

By default, health checks for individual service instances in Eureka are not implemented through the/health endpoint of the Spring-boot-actuator module, but rely on the client's heartbeat to keep the service instance alive. Unless the heartbeat stops, the service center will not remove it.

The default heartbeat implementation can effectively check whether the client process is functioning properly, but it does not guarantee that the client application will be able to provide the service properly. Because most microservices applications will have some other resource dependencies, such as database, cache, message agent, etc., if the application cannot connect to these resources, the actual service can not be provided, but the heartbeat check is still in, or will be called by consumers, so that the actual effect can not be achieved.

In spring Cloud Eureka, we can pass the Eureka client's health check to the/health endpoint of the Spring-boot-actuator module with a simple configuration to achieve more comprehensive health state maintenance.

Spring-boot-actuator module dependencies are introduced in the Pom.xml.

Adding parameter configuration eureka.client.healthcheck.enabled=true in Application.properties;

Spring Cloud Eureka Configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.