Four Hours of CPU Nobody Asked For
In October this site was suspended on Vercel's free tier and its Neon database ran out of compute. Traffic was not the cause. Pages regenerating on timers were, and removing the timers took daily CPU from minutes to seconds.
On October 21 this site stopped loading. Vercel had disabled the account for exceeding the Hobby plan's fair-use limit on Active CPU, and every page returned HTTP 402. A week later the Postgres database behind it, on Neon's free plan, used its entire monthly compute allowance, three days before the period reset.
Neither happened because of traffic. Almost all of the work was the site refreshing itself.
What was using the CPU
The usage dashboard showed a flat line: roughly 6 to 10 CPU-minutes every day, deploy or no deploy. On a plan with about four hours of Active CPU a month, that line alone spends the allowance.
Breaking the previous 30 days down by category made the shape obvious. Background page regeneration was 64.2% of the CPU; serving real requests was 35.6%. The homepage was the single largest route. And one of the steadiest consumers was mine: a half-hourly check in my homelab that verified four routes on this site had run 1,271 cycles, 5,084 requests, and was attributed about 21% of route CPU. I had built a monitor that was one of the things it should have been monitoring.
Why the database ran out too
Neon's free plan gives 100 compute-unit hours a month. Compute scales to zero after five idle minutes, and those five minutes are billed. So the cost of a query that takes 20 milliseconds is five minutes of compute, if it is the one that wakes the database.
By October 22 the project had used about 80 of its 100 hours. The database had been running for roughly 306 hours that billing period, at an average of 0.262 compute units, barely above the 0.25 floor. On October 20 alone it started 92 times and ran for 12.76 hours. Making queries cheaper would have changed nothing. The bill was the number of wake-ups, and about 150 public pages each regenerating on a timer meant something woke it nearly every hour.
The first fix helped and kept the shape
The first pass was the obvious one. Five-minute regeneration became hourly, the blog listings and Open Graph images got caches, and the homelab check stopped probing the site. CPU fell, but two problems survived it.
The first was a crawl trap I had built myself. Tag chips on the blog linked to query-string variants of the listing, which were dynamic and backed by Postgres, and crawlers walked every combination of type, tag, and page in three languages. After the first fix, that one listing was 45% of all function invocations and 23% of Active CPU.
The second was arithmetic. With 150 paths, no hourly interval can bound how often the database wakes; it only spreads the wake-ups out. There was also a subtler leak. Next.js copies a numeric data-cache TTL onto the page that calls it, so a one-hour cache deep inside a component quietly re-arms a timer on a page that was supposed to have none.
Removing the timers
The second pass removed time from the equation.
- Every database-backed public route is now generated once and kept until content changes. Saving a post or project, or a translation finishing, invalidates exactly the affected pages across all three languages. An authenticated endpoint covers the rare write that bypasses the editor.
- Data caches carry tags and no TTL, so nothing can re-arm a page timer from below.
- The bounded listing variants (six type filters, five pages, three locales) are rewritten to static routes. Tag filters redirect to the static tag pages. Only free-text search stays dynamic, and it is excluded from indexing.
- Bluesky discussion threads load in the browser through a cached endpoint, so their freshness stops dictating the article's.
- I also chose not to turn on a five-minute schedule that drains the publish-webhook queue. It would have woken the database 288 times a day. The queue drains right after a publish and again in the daily cleanup job.
What it looks like now
I measured the first twelve days of November from Vercel's observability data. Function Active CPU ranged from 6.8 to 40.4 seconds a day. There were about 700 function invocations in total over thirteen days. Regeneration writes dropped to nearly zero once every page had been generated once, and the homepage is still being served from the edge cache that was filled at the last deploy, sixteen days earlier.
The database now wakes for a short list of reasons I can name: a smoke check every six hours, one daily cleanup job, and me using the admin. In October the list was every page on the site.
What I would do differently
Treat "regenerate every N minutes" as a recurring cost, not a freshness setting. On usage-billed platforms the question is not how fresh a page needs to be. It is who pays each time it refreshes, and how many times a month that happens. For a site whose content changes when I publish, the right interval was never five minutes or an hour. It was "when I publish".
Written by
Adrian Romo
Senior Backend Engineer: Python backends, AWS, enterprise integrations, realtime voice systems, and AI infrastructure.
Related
Keep reading
The Update Cron That Patched Nothing
A weekly LXC update job fired on schedule for about sixteen months and installed nothing: a 404 script URL, with the error sent to /dev/null. Auditing every update mechanism found zeroes that meant nothing.
Instruments That Could Not Fail
A routing differential came back byte-identical against a router I had broken on purpose. It was one of several measurements in one project that reported a confident number about nothing.
The Benchmark I Tuned Against Stopped Being a Benchmark
Recall on my memory layer's tuned questions rose from 54 to 80 of 97 in one iteration. On held-out questions it went from 13 to 14 of 36. A stricter grader, a plain BM25 baseline, and one retraction.
Keep going
Where to next?
Browse more technical writing, see the engineering case studies, or reach out directly.