ASP.NET Core Web API Interview Question #148
What is the difference between liveness and readiness checks?
Error Handling, Logging, Caching, Rate Limiting, CORS & Reliability Senior Advanced
Quick Interview Answer
A liveness check answers whether the application process is alive enough to continue running. A readiness check answers whether the instance is currently ready to receive traffic.
Detailed Explanation
A liveness check answers whether the application process is alive enough to continue running. A readiness check answers whether the instance is currently ready to receive traffic.
A temporary database outage may make an application unready without necessarily meaning the process should be restarted. Separating the two concepts helps infrastructure respond appropriately.
Code Example
// Example endpoint strategy:
app.MapHealthChecks("/health/live");
app.MapHealthChecks("/health/ready");
// Configure predicates/tags so each endpoint
// runs the checks appropriate to its purpose.