Discussion Why so many environments?
I’ve worked at a lot of big companies and they always use 4+ environments to promote code. But processes are so dysfunctional that all the layers don’t reduce prod risk.
Are any companies saying to themselves, “it’s faster, cheaper, AND less risky to mostly edit in prod?
85
Upvotes
97
u/LateToTheParty2k21 5d ago
Your choice.
31
u/cooliem DevOps Consultant 5d ago
"But processes are so dysfunctional"
Yes. That's why they have so many environments. That right there.
To answer your question: Yes. The companies that have their shit together have fewer environments. If they really know what they're doing then they just have prod and non-prod. But there's often a staging area for QA/UAT type work.
48
u/jake_morrison 5d ago edited 2d ago
Some of this depends on how short your cycles are. If you have feature flags and good instrumentation, you can deploy fine-grained features into production in a safe way without huge amounts of testing.
On the other end of the spectrum, I worked with a SaaS client that had 22 different environments. Their release process took three months, with lots of manual installation and testing work. If any issues were found, fixes would spend weeks circling back to the release branch, then get tested again.
They had 4000 MS SQL Server database instances, each with customer-specific changes that had to be validated. Parts of the system were still in classic ASP that didn’t support modern automated testing and had to be manually tested.
43
u/myka-likes-it 5d ago
No. This is crazy talk.
10
u/quiet0n3 5d ago
Dev for Dev obviously it's for quick developer feedback so they can get visuals or debug logs.
Multiple test environments. Usually the amount of test environments grow based on how big your Dev team gets. The larger your Dev team the more Devs want their own environments so they don't run into other teams changes to other apps or other parts of the same app. Or it could be the mobile team etc.
You need good coordination when going to prod. We did this by having a beta environment.
All changes set to go out in the next release go into that environment for the testers to do full UAT with all the planned changes all together. We only deploy things that passed beta.
16
u/Deep-Regret-7479 5d ago
It is, until it is not.
8
u/psmgx 5d ago
less risky to edit in prod
get out
5
u/skspoppa733 5d ago
SOC 2 controls mandate logical separation of environments, so if you provide technology services to others then this choice is already made for you.
8
u/jackrackham19 5d ago
In my experience the management all believes they use the four different environments, and the devs don't have the discipline to keep their hands off of prod.
7
u/raisputin 5d ago
Dev/qa/staging/prod
Pretty goddamned standard and each one should be largely identical to prod
3
u/tacticalpotatopeeler 5d ago
No, we have development layer, staging, prod, and sandbox which is basically a stable mirror of prod that can be used to demo new features that may be behind a feature flag and not yet available, and for partners to use as a test environment, etc.
Dev can be broken, staging is a safety check before prod, we can only pick up stable staging builds to promote to prod.
So no, please do not do dev work on prod
3
u/centech 5d ago
Just because a lot of places don't do it well doesn't make it wrong. Just YOLO'ing prod is not a good plan. Especially if you are in any sort of regulated industry.
4
u/GamerFaizal 5d ago
Everyone has a testing environment. Some companies are just lucky enough to have a separate one they call production.
2
u/thelastknowngod 5d ago
This is more of a people question than a technical one. The cultures in some companies are to hire a lot of JR devs. In those situations, it's easier for them to wrap their heads around dev, qa, staging, and prod. In a company that primarily hires Sr level engineers, I would more quickly reach for canaries, feature flags, advanced routing, and modified data handling under test vs promoted to stable.
It's more about knowing your audience than anything.
1
u/dodexahedron 5d ago
Solution:
If it breaks in the prod environment, just take it out of that environment, so it's beyond the environment.
1
u/MasterOfTheWind1 5d ago
How many environments depends on how big the team is, the type of company (is not the same to develop for a customer facing product than for internal software only) and if the customers have access to some playground for example.
The number of environments by themselves don't say nothing if you don't have a good process of validation.
I've worked on places with dev, stage, rc and production, and the deves clamed that "we can only test on production because of A,B,C", so every environment were pointless.
Every environment needs a purpose and gate conditions that prevents from further advancing to the next.
1
u/Holiday-Medicine4168 5d ago
I have worked with at places that have half a dozen environments per team or per app. There can be hundreds if not thousands, that’s normal for large orgs especially in financial environments.
1
u/xanyook 5d ago
Depends on your build, release and product strategy.
I use to work on a platform where we were doing to push to prod. But i was the lead, and was doing whatever i wanted :)
The idea was that as soon as it was merged on the main, it sas delivered. But i had a dedicated tenant i was able to test on, feature flags and api versioning so my users would not see any test we were doing on production. And a defect would not impact the runnas both n and n+1 version were running in parallel.
We only had pre-production as a training environment.
But i worked on platform with 4-5 environments, waterfall model, promoting the release from one to another, going up the ladder. A release would take 6-9 months.
1
u/snarkhunter Lead DevOps Engineer 5d ago
Isolation - to isolate customers from development, development from testing, etc.
At my place we tend to have a few long-running client-specific projects going on at any given time. Those will often get their own environments, sometimes even their own dev/qa/demo.
1
u/raindropl 5d ago
There are. Lots of variation.
But you want a dev environment we’re all the merges are done. And is desirable to have feature branch environments that set deployed in every commit/merge into that environment.
Once things merge into dev and pass automated testing. They are automatically merged into E2E (End to end testing) where is supposed to be tested actors all related services. Again once it passes testing with could include escaping events and traffic. It turns a green flag indicating it can be merged. Most places will have a human gate keep. More modern teams will have a canary with blue green where changes are either tested incrementally,or be deployed in blue green where rollbacks are almost instantaneous if something is broken.
So 1 (dev) + n(feature branch ) +1 (e2e) + 2(prod blue green)
And some places have a perf. For stress test.
1
u/SouthCollar2929 5d ago
Bro my company is exactly the same. We have four environments and nobody checking my prs. Before I started there was no testing, no typechecking, no error reporting. But merges to main take weeks because we gotta be careful. Careful how? Get some internal users using the new version and if nothing breaks after a while it's good to go.
1
u/Nexus357 5d ago
What you need is Devuction
1
u/adappergentlefolk 5d ago
its cargo culting
1
u/dmikalova-mwp 5d ago
My understanding is that Facebook deploys to prod. They basically have enough trust and validation that they don't deploy problematic code, revert it quickly if they do. A lot of this is done with gating new things behind feature flags.
I'm with you - everywhere I've seen go towards more envs just have more mess. A previous company had a completely dysfunctional staging so to fix that the answer was to create a whole new environment as if that was going to change anything.
1
u/SilentLennie 5d ago
Depends on the size of the team and what you are deploying, a demo, MVP, etc. fine. do it live ! Your problem.
But for a real app, how about just 2 envs ? And check before deploy to prod.
1
u/NoDevelopment206 5d ago
i think the number of environments matters less than whether each one catches something different. a staging that is nothing like prod just adds delay and gives fake comfort. if you can get fast tests, feature flags and an easy rollback, fewer environments works fine. the extra layers make sense when many teams share one big system and need a place to test together.
1
u/VeryShibes 5d ago
Pilot, Dev, QA, Performance, Stage, Prod here.
Most developers here stopped using Pilot and Dev years ago and deploy straight to QA then skip Perf and promote to Stage and Prod. Performance is only if your application is bloated and/or has a ton of outside dependencies and needs to be tuned with APM tools
1
u/riki137 5d ago
Editing in prod is never a good idea. I've worked in companies with 10 environments and the reasoning was so that we can deploy specific features to test for external testers. Maintaing feature flags is definitely more work than maintaining 10 identically programatically set-up environments, especially if you need to do a major refactor.
1
u/hi117 5d ago
I'm going to take a different tack and say that you don't "need" any environment except prod while still following all best practices. The best practices don't say to have a testing environment, they say to test before deploying to prod. For most setups, there's little reason you can't mimic a prod setup (for functional testing at least) on a developer's laptop.
Now for ad hoc changes to prod, that actually happens more than most realize. Every scaling event is a change shipped straight to prod technically. Config changes are more of a risk assessment approach. More specifically, everything is a risk assessment, which is kind of what you were saying to begin with.
1
u/Mean_Guest_5043 5d ago
I think the number of environments matters less than how well they're maintained and how closely they reflect production.
1
u/mrzerom 5d ago
The more active develoonent touching different areas of an app, the more useful it is to have more environments, specially if data security is a concern.
Usually integration > uat > prod is enough. But if your company needs to provide external access to clients, then having a pitch/demo env also makes sense, then you add hotfixes, they should still go through integration tests, but do you bypass uat and go directly to prod? Wont it disturb live development? Maybe add hotfix specific integration testing env, etc.
Everything sounds simple when you're looking from the outside, but unless you have a nutty engineering/architecture lead, environments are created to solve real needs and simplify the sdlc.
1
u/Hostman_com 5d ago
Start with the last three bugs that made it through to production. Try reproducing each one outside prod with the affected build. Figure out whether the gap was in the test data, configuration, a dependency or the test itself.
Use those gaps to decide what to fix or combine. If two environments repeat the same checks under the same conditions, merging them may make sense. If neither catches a known failure, removing one won't fix that gap.
1
u/angellus 4d ago
A lot of it depends.
But generally I do think 4-5 environments is the "right amount".
I have worked at 2 places where we had an environment that was literally prod, but we just swapped a Web server. Same database as prod. This can largely be replaced with feature flags nowadays, but the extra isolation layer was still really nice.
1
u/NoDevelopment206 4d ago
i think the number of envs matters less than how close they are to prod. a staging that has different data and configs just gives false comfort. editing closer to prod can work if you have feature flags and a fast rollback, otherwise one bad change hits everyone at once. does anyone here actually run with only 2 envs?
1
u/nekokattt 4d ago
Probably the ones that have outages every five minutes, or fewer users than developers.
1
u/dogfish182 4d ago
Lots of companies say that. Shit companies
1
u/cliffberg 4d ago
You are right. The four environments thing originates from pre-devops days. With a DevOps approach, you only need a static prod environments - the others should be created on demand. Code changes should be integration tested in a fresh prod-like env, with well-defined prod-like datasets that get provisioned into the dynamically-created test env. And when deploying to prod, you should do a canary deployment and gradually switch over if there are no problems. There is no good reason to have multiple static test environments - doing that is an anti-pattern.
1
u/mcloide 4d ago
In an ideal world, where everything works as intended, you would have:
In reality, you can comfortably operate with:
However, when an emergency hotfix is required, what often happens is:
Neither should be the standard operating procedure, but reality doesn't always respect the ideal workflow.
Having more environments doesn't necessarily reduce production risk. Each environment needs to serve a purpose, and the processes surrounding it need to be respected.
Processes do work. The problem is getting people to follow them (actually good luck with that).
1
u/Aoxite 4d ago
my company does hospital dbms and after we switched to prod only things got so much cheaper and faster it's great 😃
1
u/forest-cacti 2d ago
Sorry in advance for the long reply, but this is something I've been chewing on a lot lately as I reflect on my different engineering experiences.
Before I jump into my thoughts, I'm genuinely curious about your setup:
• What do those 4+ pre-prod stages actually look like at your company?
• Do any of them give you true parity with prod, or are they all watered-down approximations?
• Are you practicing continuous delivery, or are changes batched into scheduled release days?
I've worked on both ends of the spectrum. At one mid-sized company, we had multi-stage promotion and scheduled deploys. Over time, every past outage turned into a new item on a manual pre-deploy checklist. Pushing code became this precious, high-ceremony event where the main goal was avoiding hotfixes, yet things still slipped through because staging never matched real traffic.
Later, I worked in a much larger environment practicing trunk-based development and true CI/CD. Small changes merged to main and flowed automatically through isolated pipeline stages with strict blast-radius controls and automated rollbacks. Even there, though, there was a glaring blind spot around developer experience: leadership demanded thorough testing before you even opened a PR, yet there wasn't a clear, documented way to spin up a safe sandbox to test half-finished work without triggering broken pipeline checks. Telling engineers to "just be more careful" instead of investing in safe pre-merge sandboxes is a massive cop-out.
This has also been on my mind because I recently started re-reading the (20th Anniversary Edition) of The Pragmatic Programmer, and there is an idea right near the beginning that connects directly to this. The authors argue that almost every solid software principle boils down to one rule: Good Design Is Easier to Change Than Bad Design (ETC).
Most people only link that idea to writing clean, decoupled application code, and they stop there. In my opinion, it applies just as much to deployment pipelines and infrastructure.
Every approach has tradeoffs, and multi-stage workflows exist for a good reason: nobody wants to bring down all of production, and true canary testing is genuinely hard to pull off.
If you accept that change is inevitable, though, "easier to change" means prioritizing fast feedback and small blast radii over heavy pre-prod gates, whether that is safe pre-merge sandboxes, single-host smoke tests, or progressive rollouts across isolated clusters or geographic shards.
Even then, a change can pass every pre-merge check and roll out cleanly to the first few clusters before hitting a subtle configuration quirk in a later one, which is exactly why progressive isolation matters.
The biggest realization I've had, especially after building my own home lab setup, is that true dev-to-prod parity isn't just expensive on paper. In many systems, it isn't even architecturally possible.
When I tried to stand up a "staging" instance for my own network controller, I quickly realized you simply cannot have two active instances managing the same underlying physical infrastructure unless you build a whole second network from scratch. Real-world state, external integrations, and exclusive resource ownership mean you can't just clone production into a neat little box.
Pre-prod environments are great for catching deterministic bugs (unit tests, mocked integrations, basic form and API logic). Beyond that, you get way more safety from small, frequent merges, feature flags, contract testing, and progressive rollouts with fast automated rollbacks seems to address the risks that staging layers alone rarely catch.
Of course, this is just my take based on the setups I've worked in. I keep hearing that there are teams out there with genuine pre-prod parity or true isolated canary environments, even though both feel almost mythical from what I've seen firsthand. For folks who have actually pulled off either one, or found a completely different way to ship safely without heavy staging layers, what does that look like in practice?
1
u/zenspirit20 2d ago
Have you measured what kind of bugs get found in pre prod? There is always going to be some prod risk because new code is getting deployed, the question is if the energy spent in pre prod is being spent in desired areas
1
u/tambien430 1d ago
Extra enviroments earn their keep when each one answers a different question since dev stageing and production drift apart the moment configs stop matching Bootdev could help build the backend and deployment base behind such setups though platform docs also map the patterns
1
u/DampierWilliam 1d ago
One environment per developer or app in your product. Then one per stage: dev, qa and staging. One environment per feature demos.
But what we really want as DevOps is the One Environment. One Environment to rule them all.
1
u/sokjon 5d ago
Safely testing in production is a well understood, well-trodden path now. Anyone that suggests otherwise doesn’t understand the techniques and patterns required to do it safely.
Are there benefits to extra environments? Absolutely. But the returns are diminishing after an extra one or two of them. After that they turn into fragility, lag and actually a real risk.
1
u/thisFishSmellsAboutD 5d ago
Microsoft for example seems to do that. Their track record with successful products like Office 364 attests to that.
0
u/__bhavin__ 5d ago
Editing in prod is how you find out which customer was the test case. But you're half right: past the first staging env, most of the extra layers re-run the same checks on the same fake data.
Staging is good at obvious breakage. It won't tell you if the route three people hit a day still works, and neither will the two envs after it. What actually lowers risk is cheap rollback. Run old and new side by side with a small slice of real traffic on the new one, and make going back a weight change on the load balancer instead of a redeploy. Real traffic finds the breakage and most users never see it.
I'd cut environments once the way back is that cheap. Not before.
0
u/Amekaze 5d ago
For me you really only need live 2 non prod environments. The Wild West and the Exact Copy. Anything more requires special circumstances for it to make any sense. From my experience the more environments a place has the worse their local development is because if code can be pushed in a state that completely bricks a live environment then the developer doesn’t have enough resources in the local environment to properly do their job. Deploying code shouldn’t be a step in the middle of a development process.
0
u/catcherfox7 5d ago
That the case of company that I recently joined.
Put the costs in papel, show them the risks don’t disappear with existing practices and what the industry is doing and the see your CTO turn into the biggest advocate for reducing the number of environments.
0
u/addy3006 4d ago
Most extra environments end up as process rather than risk reduction, because staging rarely matches prod's data, traffic or config. I'd keep two: a cheap one for fast testing, and prod. Then lean on feature flags, canary releases and quick rollbacks to catch what staging misses. Editing straight in prod works only when changes are small, observable and easy to undo.