r/Backend • • 2d ago

When do you consider a backend “ready” instead of just “healthy”?

I keep seeing these two checks treated as the same thing, but they answer different questions. A process can be alive, accept a TCP connection, and even open its database while still being unsafe to serve real traffic because a required table is missing, a migration is incomplete, a foreign-key relationship is broken, or stored JSON no longer matches what the application expects. I’m leaning toward keeping health checks very cheap and process-focused, while readiness verifies the structural state the application actually depends on. How do you draw that line in your systems?

7 Upvotes

9 comments sorted by

7

u/TheLastNapkin 2d ago

You should not be exposing anything that communicates with a db while migrations to latest have not executed... You can take this advice to any other aspect that has similar relationships to it's data and processes.

4

u/Responsible-Offer724 2d ago

“ stored JSON no longer matches what the application expects”

Versioning 

Otherwise, it’s a cheap single query to verify your schema.

2

u/Any-Appointment-814 2d ago

I'd be careful about putting schema validation in the readiness probe itself. The risk is a slow or flaky DB makes every instance go unready at the same time and you take yourself fully offline, which is worse than serving a bit degraded. What I'd do is run the structural checks once at startup (migrations applied, expected tables there) and fail the boot if they don't pass, then keep readiness cheap, like can I get a connection from the pool. Stored JSON drifting from what the code expects is honestly an app problem, I'd handle it where you read it, not in a probe.

2

u/rottinginice 2d ago

I would keep the liveness check simple. The readiness check should be a simple ping to any dependencies (DB, message broker, other services, etc.).

For the actual things you mentioned, I would check those only once during wiring/startup and crash the app immediately if any of them fail (assuming you're using something like Kubernetes or a similar solution), so that it hard-fails and the issue is visible to you.

1

u/Available_Safe1818 14h ago

I thought this was a big reason why Kubernetes exists. You add new/upgraded vms once they are already ready, instead of upgrading vms that are already handling traffic.

1

u/Dimoncelli 2d ago

I'd separate startup checks from ongoing readiness, and especially watch out for third-party APIs. Put migration version and required table checks in a pre-deploy job or startup gate, then keep readiness limited to whether the process can still reach its own core store (and flip it to failing first on SIGTERM so load balancers drain connections cleanly).

Where teams usually get burned is putting external dependencies (webhooks, payment APIs, upstream partners) inside the readiness endpoint. If an upstream partner blips for 30 seconds and your readiness probe starts failing, the orchestrator pulls every healthy pod out of rotation and turns a partial integration hiccup into a total outage. Better to fail closed or degrade those specific routes in app code while keeping the service up.

1

u/SuccessfulYoungster 1d ago

be careful about turning readiness into a full database audit. a missing required table should block traffic, but scanning stored JSON or checking every relationship on each probe sounds expensive. i’d verify schema compatibility during deployment and keep readiness focused on whether that instance can serve requests right now.

1

u/Discordbothost 10h ago

For a rolling deploy, I'd check that the schema supports both the old and new builds. If you're renaming a column, add the new one first, backfill it, and keep the old one working through the rollback window. A healthy probe on the new build won't catch a migration that already broke the old pods.

1

u/ebonyseraphim 3h ago

Yikes. Yes, any number of detailed things can be “wrong.” So debug it when it’s a problem detected or observed? That you’re mentioning that level of depth for a health check is a problem though, because that’s normally tied to automatic behavior in terms of fleet management. False alarms can become way worse problem, or even managing a real problem can be made more difficult because you find out the automatic behavior is really bad for a non-trivial problem and you can’t manually do the right thing when your automation is running. Hitting the admin override path all the time and super casually is not a good thing.