See https://github.com/spring-projects/spring-boot/issues/2652
I submitted a PR for this issue before, but it wasn't very good. I hope this one is better.
Problem: Right now, invoking the health endpoint lead to a synchronous invocation of all underlying HealthIndicator instance(s) that have been configured. It would be nice to offer an option to run these in parallel instead.
Real world example: I have a number of HealtIndicator components that poll remote systems and report on latency and status, and the latency really adds up, especially if there are time-outs involved.
Solution: This PR adds a ConcurrentCompositeHealthIndicator that can run the HealthIndicator instances on the ThreadPoolTaskExecutor.
Usage in code:
@Bean
public HealthEndpoint healthEndpoint(HealthAggregator healthAggregator,
HealthIndicatorRegistry registry,
ThreadPoolTaskExecutor executor
) {
return new HealthEndpoint(
new ConcurrentCompositeHealthIndicator(healthAggregator, registry, executor, Duration.ofMillis(1100)));
}
Comment From: snicoll
@rikende did you mean to close this PR?
Comment From: RikEnde
While working on this, I found it could be solved at the application level once we move to spring boot 2.1.x
@snicoll I'm really sorry for wasting your time. I felt less good about this PR every day, and now that I have a workaround, I can't justify working on it during the day.
Comment From: CLOUGH
@RikEnde could you share the workaround that you found.
Comment From: RikEnde
@RikEnde could you share the workaround that you found.
The code from this PR could be implemented entirely in domain code, requiring no framework changes. However, this was 2 years old. It doesn't even compile against the current version.