2

I have read in the Spring cloud documentation about the Spring Eureka used for Microservices. Also, read the Eureka Server would receive the heartbeat from the client who has registered with the Eureks Server.But I am not able to understand, why do we have this eureka.client.healthcheck.enabled=true. Client sends the heartbeat at every regular interval and what's the use of healthcheck ? Is it for the custom healthcheck for a service?

narendra-choudhary
  • 4,582
  • 4
  • 38
  • 58
Sri
  • 13
  • 2
  • 5

1 Answers1

1

From Spring docs:

By default, Eureka uses the client heartbeat to determine if a client is up. Unless specified otherwise, the Discovery Client does not propagate the current health check status of the application, per the Spring Boot Actuator. Consequently, after successful registration, Eureka always announces that the application is in 'UP' state.

This behavior can be altered by enabling Eureka health checks, which results in propagating application status to Eureka. As a consequence, every other application does not send traffic to applications in states other then 'UP'.

This property is to tweak how Eureka client reports it's alive status to server.

When this property is enabled, client application will send health status (the same health status reported by /health endpoint of Actuator framework) to the Eureka server, and server will use this status to determine if server should advertise hostname/IP of this particular application to other applications.

You can customize what information is collected for reporting status at /health endpoint.

Example: You can configure health endpoint to return "DOWN" when database connection failure rate cross a certain threshold. In that case, this application is no good even though it has not actually crashed. All endpoints still return some HTTP code other than 404, but the application as a whole is no good because database connections are failing.

With this database health check added to default health aggregation logic, client will report "DOWN" to Eureka server, and server will NOT advertise this specific application/instance to other applications/instances.

narendra-choudhary
  • 4,582
  • 4
  • 38
  • 58
  • It would be so nice to see an example how to register custom "database health check". – Yan Khonski Jul 29 '20 at 15:07
  • 1
    @YanKhonski Check this question: [How to add a custom health check in spring boot health?](https://stackoverflow.com/questions/44849568/how-to-add-a-custom-health-check-in-spring-boot-health) – narendra-choudhary Jul 29 '20 at 15:16