Assuming you have an internal service (ie inaccessible by the public), is there any benefit to having the health check run on a different port from the service? I feel like if it runs on a completely different port, it's less able to detect whether there's a problem with the actual service. Yet having a service and health port is something I see recommended quite frequently.
not kotlin but kotlin colored 2
10/17/2023, 9:07 PM
the recommendation is to have a separate port for metrics, because you want the metrics port to stay responsive even when your normal service port is overloaded.
Viorel Ștefan Alexandrescu
10/18/2023, 7:56 AM
Depends on your approach, an idiomatic way used in Spring Boot is to have a dedicated endpoint (perhaps they consider that if you a thread-per-request configuration, it shouldn't be blocked by anything).
But, if you are willing to have another process/thread running in parallel on a different port, you should consider the implications (how you wire this in your app's architecture).
Honestly health checks, as stated above can be made using metrics and then perhaps wired through a metrics server, which (if configured correctly), should point out soon enough if your service is encountering issues.
TLDR: Have atleast an endpoint to check, other solutions need to be treated on a case by case basis.