The autoscaler adds a node during a traffic spike, the new container reports healthy, and the first wave of requests routed to it waits 4-to-8 seconds before the first byte. Existing nodes are responding in 80 ms. The spike is half over by the time the new node is useful.
What’s happening
A “ready” container from the orchestrator’s point of view is not a warm Node process from your application’s point of view. The platform marks the instance healthy as soon as the listen socket accepts a connection. Between that moment and the first useful response, a Node app typically does a non-trivial amount of work that no health check observes:
- Cold module graph.
require()on a typical Express/Fastify app touches hundreds of files; the V8 code cache is empty. - First database connection. Most ORMs lazy-connect on first query, then negotiate TLS and authenticate.
- First secrets fetch. If you read from a secrets manager per request, the first request pays the round-trip.
- JIT warm-up. The first hundred requests are measurably slower than the next hundred thousand.
On managed PaaS this is the entire cold-start cost. There is no Lambda-style freeze; the container is yours. It just hasn’t done the work yet.
How to verify
Time the actual phases on the instance. From the container shell:
node --inspect-brk app.js
# or, with built-in profiling:
node --cpu-prof --cpu-prof-dir=/tmp app.js
In production, log timestamps at the top of index.js, in the app.listen() callback, after first DB query, and after first secrets call. The gap between “listening” and “first DB query handled” is your real cold-start window.
Sanity test: hit /healthz ten times in a row on a fresh instance, then time /your-hottest-endpoint. If the hot endpoint is 5× slower on hit one than hit ten, V8 warm-up is part of it.
The fix
- Add a readiness probe distinct from liveness. Don’t accept production traffic until the app has connected to its database, fetched its secrets, and serviced one warm-up request internally.
- Boot a warm-up routine in
app.listen()’s callback: pre-call the three or four hottest internal endpoints againstlocalhostso the module graph is loaded and V8 has profiled the hot paths before the load balancer sends real traffic. - Move secrets and config to environment variables or fetch them once at boot.
- If you can justify the build complexity, V8 startup snapshots (
--snapshot-blob) cut module-load time by 30–50% on apps with large dependency trees.
The fix is not bigger instances. The fix is making “ready” mean ready.
Stack Harbor’s Cloud PaaS service ships readiness-probe templates as part of the standard runtime — talk to us.