STORM

SOFTWARE  DEVELOPER

SYSTEM  INITIALIZING

[ VIEW PORTFOLIO ]

01
Back to Blog
Backend

Why Your Backend Goes to Sleep (And How to Keep It Alive)

April 27, 2026 4 min read

If you've built a project on a free-tier hosting service - Render, Railway, Fly.io, or similar - you've probably run into this: the first API call after a period of inactivity takes 30 seconds or more. After that, everything is fast again. Then it goes quiet, and the problem comes back.

This is called a cold start, and it's a deliberate feature of free-tier infrastructure, not a bug.


What Is a Cold Start?

When your server receives no traffic for a certain period (typically 15 minutes on Render's free tier), the hosting platform spins down the container to save resources. Your code is no longer running.

The next incoming request has to:

  • › Spin up the container from scratch
  • › Start the Node.js (or Python/Go/etc.) process
  • › Connect to the database
  • › Load your application into memory
  • › Then finally handle the actual request

All of that takes time - often 20–40 seconds. From the user's perspective, the app just looks broken.


Why Platforms Do This

Free plans have to be economically viable. A server sitting idle 23 hours a day consuming CPU and RAM isn't something a platform can offer for free indefinitely. Spinning down idle instances is how providers like Render, Railway, and Fly.io keep free tiers available at all.

Paid plans typically disable this behavior and keep your server always-on.


How to Keep Your Backend Alive

Option 1 - Use a Ping Service (Simplest)

Services like UptimeRobot (free) or Freshping let you send an HTTP GET request to your server on a schedule - every 5 or 14 minutes, for example.

  • › Sign up for UptimeRobot (free)
  • › Create a new "HTTP(s)" monitor
  • › Point it at any endpoint on your backend (e.g., https://your-api.onrender.com/health)
  • › Set the interval to 5 minutes

Your server receives a request before the inactivity timer ever runs out. The platform never spins it down.

Option 2 - Add a /health Endpoint

If you don't already have one, add a lightweight health check route:

js
// Express
app.get('/health', (req, res) => res.json({ status: 'ok' }));
python
# FastAPI
@app.get("/health")
def health(): return {"status": "ok"}

This gives the ping service a safe, cheap endpoint that doesn't hit the database or run any business logic.

Option 3 - A Scheduled Serverless Function

If you have a Vercel or Netlify frontend, you can use a serverless function with a cron trigger to ping your backend:

json
// vercel.json
{
  "crons": [{ "path": "/api/ping-backend", "schedule": "*/5 * * * *" }]
}
js
// app/api/ping-backend/route.js (Next.js)
export async function GET() {
  await fetch(process.env.BACKEND_URL + '/health');
  return Response.json({ pinged: true });
}

Option 4 - Upgrade to a Paid Plan

If your project is being used seriously, the right answer is to move off a free tier. Most platforms offer a starter plan for $5–7/month that keeps your server always-on. Cold starts are a tradeoff of free hosting, not a permanent constraint.


What About Serverless Backends?

If your backend is a serverless function (AWS Lambda, Vercel Functions, Cloudflare Workers), cold starts work differently. Each function invocation is stateless - there's no persistent server to spin down. Cold starts still happen when a new function instance is created, but they're typically much shorter (under 1 second for most runtimes).

For serverless, the mitigation is provisioned concurrency (keeping a certain number of instances warm) - but that's a paid feature too.


Quick Reference

PlatformFree tier behaviorIdle timeout
Render (free)Spins down after inactivity~15 minutes
Railway (free)Spins down, limited hours/month~5 minutes
Fly.io (free)Scales to zeroConfigurable
Vercel FunctionsStateless, cold starts per invocationN/A

The fix is simple: ping your server every few minutes. A free UptimeRobot account is all you need to keep a free-tier backend always-responsive. It takes five minutes to set up and solves the problem permanently.

Back to Blog
PLAYING