Search code examples
springspring-bootspring-mvcspring-boot-actuatorhealth-monitoring

Third party health endpoint best practices


I am developing an application and using spring-boot-application for my health endpoint, my application is interacting with several third party services which I need to include in my health check, the problem is when the services does not respond I keep waiting until the ping times out so I know they are not available , this takes long time and I want to avoid this.

One solution was to run all the check for the services in parallel, this will reduce the time incase of the timeout significantly but still I have a bottleneck of one timeout. Another solution would be to keep checking the services in the background periodically (using scheduler) and cache the last result of the check so when our monitor asks for health information, health endpoint will return the cashed result.

Are there any more practical solutions? Or are there any known best practices for such a scenario?


Solution

  • I want to post how I tageled this issue:

    Since The application is dependent on third parties and without the connection to these third parties the application is not considered functional ( not a microservice ) there was no escaping checking the health of these third parties

    To address the issue I did the following:

    1- Identify the critical third parties, the application connects to various third parties, some of them are critical and some of them are not (most probably this will involve a business decision), so it is important to identify the critical third parties, for the non-critical third parties I excluded them from the health check

    2- Perform a periodic check for the health of the critical third parties and cache it, ofc this will introduce a delay in fetching the health so the period of the check should be agreed on, for me it was ok to have a small delay ( 3 mins) so this was the interval of the period for me