ASP.NET Core Interview Question #221
What are health checks used for during deployment?
Testing, Deployment & Hosting Senior Advanced
Quick Interview Answer
Health checks help deployment infrastructure determine whether an application instance is alive and ready to receive traffic.
Detailed Explanation
Health checks help deployment infrastructure determine whether an application instance is alive and ready to receive traffic.
A deployment system can start a new version, wait until readiness succeeds, and only then route production traffic to it. If an instance becomes unhealthy, a load balancer or orchestrator can remove it from service.
Health endpoints should be fast, reliable, and designed so a temporary dependency issue does not accidentally create a destructive restart loop.
Code Example
builder.Services.AddHealthChecks();
var app = builder.Build();
app.MapHealthChecks("/health");
app.Run();