Architecture · By Rivtor · Updated
Liveness vs readiness checks for database-backed APIs
Liveness asks whether a process is functioning; readiness asks whether it should receive traffic. Keep checks bounded and separate them from a full user-journey test. A deep dependency check used as liveness can cause unnecessary restarts during an external outage.
See the Rivtor deployment workflow →
Define the question each probe answers
A process can be alive while its database is temporarily unavailable. Restarting every API instance in response may worsen the incident without repairing the database. Conversely, an HTTP listener can answer while the application cannot serve useful requests.
Choose checks according to the host’s actual health interface. Some platforms expose one configurable path rather than distinct liveness and readiness controls. Do not imply that copying Kubernetes terminology creates those separate behaviours on every host.
Keep the checks narrow
| Check | Intended signal | Limitation |
|---|---|---|
| Process/HTTP liveness | Event loop or server responds | Does not prove DB access |
| Readiness | Required dependencies meet a bounded check | Does not prove every feature |
| Synthetic journey | Representative business operation succeeds | More expensive and potentially stateful |
Use short, bounded database probes where appropriate. Avoid running migrations, large queries or external model calls in a health handler. Never expose credentials, detailed topology or customer data in the public response.
Handle startup and dependency failures deliberately
Record expected startup time and migration sequence. A service that is still initializing should not be confused with one permanently failing to import. Choose timeouts and failure thresholds supported by the host rather than an overly aggressive polling loop.
On Rivtor, inspect health_path and release configuration. Confirm what the platform does with a failed check and whether the endpoint requires authentication. A protected path returning a login redirect may not represent service readiness.
Verify from the real network path
Request the configured path through the intended hostname and inspect status, redirect behaviour and response time. Then test a synthetic database-backed user operation separately. A SELECT 1 check proves a simple query, not that the current schema supports a customer transaction.
In a disposable test, simulate a database outage and observe the process and host response. Record what is restarted, excluded from traffic or left running. Keep health evidence distinct from a claim that the entire application has been functionally verified.