skip to content
Serafim Sukhenkiy

My staging is a full copy of prod. It costs nothing extra.

On one of my projects I keep a staging environment - a second copy of the whole system, running the same code as the live one, where you can try things without breaking anything real.

Most staging environments are disappointing, and it’s usually the same story. Either it’s a stripped-down version - smaller database, made-up data, half the services missing - or it’s an honest copy, and you’re paying a second production bill every month for it.

Both of those come from the same place. Staging costs about as much to run as production, and it earns nothing. So it loses every budget argument it’s ever in, and pieces get cut out of it until it’s cheap enough to justify.

Mine runs on a machine I already own. So nothing had to be cut.

What’s in it

A complete second copy of the app. Web server, background workers, the scheduler, a worker for the heavy jobs. Plus its own copy of everything underneath: its own database, its own cache, its own file storage, its own mail server.

The last two aren’t the real AWS services. File storage is an S3-compatible server running inside the cluster. Mail goes to a fake mail server that catches every message and shows it on a web page instead of sending it. Both speak the same protocol as the real thing, so the app code doesn’t change at all. Only the address it connects to changes.

That buys me four things:

  • It can’t touch production data. Different database, different cache, different storage. Not the same server with a different login - actually separate.
  • It can’t email a real person. Every message it sends gets caught inside the cluster. There’s no route out.
  • It can’t post into chat. Those credentials are empty on purpose, so that code runs and does nothing.
  • It has its own front door. Its own load balancer, its own firewall rules. Poking at staging can’t reach production, even by accident.

The expensive hardware is split the same way. Production has its own, staging has its own, and they don’t share. A heavy staging job can’t slow down a real one, and nobody has to ask permission first.

Getting real data in, without handing real data around

An empty staging environment isn’t much use. Most bugs only show up on data that looks like the real thing.

So staging gets loaded from an actual production project. One command copies everything belonging to that project, pulls in the files it points at, and takes the people out of it along the way. Email addresses get replaced with a fake domain that can’t receive mail. Passwords get replaced with a single throwaway value. Then the whole lot gets packed into one file and uploaded. Those files never go in git.

On the other end, one command pulls it down and loads it. Or I click a button in the admin, which does the same thing.

What this lets me do

Here’s the part I didn’t see coming. Once staging stops being a compromise, you start using it for things you’d never risk otherwise.

I can break it. Resetting is one command. So “let’s just try it and see” stops being a scary sentence. Run the migration. Run the thing that deletes stuff. Break it properly, then put it back in two minutes.

I can hand it to someone. It’s a real, complete, working copy with realistic data and nobody’s actual details in it. That’s a much better thing to hand a tester than production and a promise to be careful.

I can turn it off. Scale everything down to nothing and the data stays where it is. When staging isn’t being used it’s genuinely off, and the hardware goes back to doing production work. That’s not a lever you have when your environment is a pile of rented servers charged by the hour.

Takeaway

Most staging environments are bad, and it isn’t because people don’t care about them. It’s that staging costs real money and brings in none. So it loses every budget argument, year after year, and what’s left is something nobody would have chosen to build.

Owning the hardware makes that argument go away. A second copy on a machine that’s already running and already paid for costs almost nothing on top.

And once the copy is honest, staging turns into the place where you do the things that are too dangerous to do anywhere else. That’s the real return for me. Not the money saved - the fact that having a second full environment stopped being something I had to justify.