Engineering
How one uptime monitor used 80% of our database allowance
Published
XBio runs on serverless Postgres with a free allowance of 100 compute-hours a month. In the first week of September 2026, with no users at all, we had spent 80% of it.
The cause was a monitoring check we did not remember setting up, and a cache that looked fine on paper. This is how it happened, and what we check now.
Serverless databases bill for being awake
Our database provider bills for compute time, not for queries. When nothing connects for about five minutes, the database suspends and costs nothing. Every new connection resets that timer.
So the question that matters is never "how many queries". It is "does anything stop the database from going back to sleep". One query every four minutes, forever, costs as much as a database that is busy around the clock.
The first fixes were real, and missed
The allowance ran out once in August. We fixed what we found: background tabs polling the server, a sitemap that queried during the build, and a health-check route that ran through more code than it needed to. Every fix was real, and we checked each one shipped. A month later the bill was growing just as fast.
Checking that a fix exists is not the same as checking the problem is gone. For a database that should sleep, the only real check is whether it sleeps. Ours hadn't suspended once since August 17.
What was actually keeping it awake
Our error-tracking provider had created an uptime monitor for us automatically. It requested the homepage once a minute, from rotating regions around the world.
Every request to the site runs through a small piece of middleware that checks the visitor's IP against a block list, and the block list lived in Postgres behind a 60-second in-memory cache. The cache lasted exactly as long as the gap between checks, and each region hit a different server instance anyway, so it never hit. That was about 1,440 queries a day against a table with no rows in it. Over one week the database was awake for 165.7 of 167.5 hours.
The health-check route we had carefully fixed in August received 2 requests in that same day.
The fix
The block list moved off the database onto an edge key-value store built for reads on every request. Postgres stays the source of truth, and the admin tools republish the list whenever it changes. The monitor now checks the health route, which caches a successful probe for hours.
Ten minutes after the deploy, the database suspended for the first time in three weeks.
What we check now
- Measure the outcome, not the fix. For a sleeping database that means its suspend events, not a list of merged pull requests.
- List every external caller: uptime monitors, cron services, CI. The one that cost us was a service nobody remembered configuring.
- A cache that expires at or below the idle window is not a cache. It has to outlast the timer it is meant to protect.
- Nothing on the per-request path reads the database unless the page itself needs it.
- When rendering moves from the browser to the server, ask again who can trigger the query, and how often.
Questions
- Does a once-a-minute uptime check really cost that much?
- On a database that bills for time awake and suspends after about five minutes idle, yes: any check more frequent than the idle window keeps it awake permanently, however cheap each query is.
- Should I point uptime monitors at a health endpoint?
- Yes, and make it a cheap one. A homepage can stay green through a full database outage, while a health route that caches its successful database check answers the real question at almost no cost.