4

How health indicators should be properly configured for Spring Boot service running on top of Kafka Streams with DB connection? We use Spring Cloud Streams and Kafka Streams binding, Spring-Data JPA, Kubernetes as a container hypervisor. We have let say 3 service replicas and 9 partitions for each topic. A typical service usually joins messages from two topics and persist data in a database and publish data back to another kafka topic.

After switching to Spring Boot 2.3.1 and changing K8s liveness/readiness endpoints to the new ones:

  • /actuator/health/liveness
  • /actuator/health/readiness

we discovered that by default they do not have any health indicators included.

According to documentation:

Actuator configures the "liveness" and "readiness" probes as Health Groups; this means that all the Health Groups features are available for them. (...) By default, Spring Boot does not add other Health Indicators to these groups.

I believe that this is the right approach, but I have not tested that:

management.endpoint.health.group.readiness.include: readinessState,db,binders
management.endpoint.health.group.liveness.include: livenessState,ping,diskSpace

We try to cover the following use cases:

  • rolling update: not available consumption slot (idle instance) when new replica is added
  • stream has died (runtime exception has been thrown)
  • DB is not available during container start up / when service is running
  • broker is not available

I have found a similar question, however I believe the current one is specifically related to Kafka services. They are different in it's nature from REST services.

Update: In spring boot 2.3.1 binders health indicator checks if streams are in RUNNING or REBALANCING state for Kafka 2.5 (before only RUNNING), so I guess that rolling update case with idle instance is handled by its logic.

Robert Gonciarz
  • 363
  • 2
  • 8
  • 15

0 Answers0