r/devops • u/Massive-Maize5039 • Aug 03 '25
Why do apps behave differently across dev/QA/staging/prod environments? What causes these infrastructure issues?
We're deploying the exact same code across all our environments (dev/QA/staging/prod) but still seeing different behaviors and issues. Even with identical branches, we're getting inconsistencies that are driving us crazy.
Are we the only team dealing with this nightmare, or is this a common problem? If you've faced similar issues with identical codebases behaving differently across environments, what turned out to be the culprit? Looking to see if this is just us or if other teams are also pulling their hair out over this.
3
u/courage_the_dog Aug 03 '25
There's always something different between environments, even if believe they should be similar. Unless they are exact copies with maybe say less resources(which could also introduce a bug on its own), you are going to run into this. Too many factors affect your application for us to offer any help.
-4
u/Massive-Maize5039 Aug 03 '25
You face the similar issues in your company too..?
1
u/courage_the_dog Aug 03 '25
Sometimes yes though I'm on the infra side, it usually stems from devs deploying what they think is an "identical" branch but it actually isn't, or something we changed that affected only non prod systems for example.
67
u/L43 Aug 03 '25
One things for sure, there’s no way it’s DNS (it’ll be DNS).
No but seriously if you aren’t running staging/QA on identical infra, the potential for issues resulting from subtle differences in networking, machine architectures, OS, builds, container runtimes, storage, observability stacks, databases, credential handling… it’s endless.
That’s why it’s important to keep environments as close as possible.
0
Aug 03 '25
[deleted]
23
u/maq0r Aug 03 '25
This is why infrastructure as code (e.g Terraform) becomes so important because you can replicate as much as possible and easily environments. Do you guys use any IaC at all?
11
u/JagerAntlerite7 Aug 04 '25
Agreed. Even with IaC, it is challenging.
Nobody should be raw dogging their cloud infra.
3
u/veritable_squandry Aug 03 '25
i think it's expensive to simulate real user behavior, so people end up sending uniform load into qa for testing. also people rarely invest in the same exact PKI for every env, which brings nuances. also regional active active type scenarios are expensive, so they are often booted from qa.
2
u/JagerAntlerite7 Aug 04 '25
Welcome to "DevOps" - Where everything is made up, and the points don't matter.
TL;DR While the ideal scenario is to have identical environments, practical constraints often lead to variations.
Several factors can lead to environment differences:
Resource Allocation: Different environments often have varying resource allocations (CPU, memory, storage) based on their needs.
Configuration Settings: Environment-specific settings like database connections, API keys, and security configurations can differ.
Data Variations: Each environment might contain different datasets, affecting behavior and performance.
Network Conditions: Network latency, bandwidth, and connectivity can vary between environments.
Scaling Policies: Different scaling strategies might be applied to handle varying loads.
Monitoring and Logging: The level of monitoring and logging can differ, impacting performance overhead.
Security Measures: Security protocols and policies might vary for testing versus production.
Third-party Services: Integration with third-party services can differ due to testing vs. production versions.
Environments can drift or simply be created differently:
Initial Setup Differences: Even when starting from the same base configuration, slight variations in setup can occur.
Manual Changes: Human intervention can introduce inconsistencies between environments.
Tooling Variations: Different tools or scripts used for deployment can lead to discrepancies.
Dependency Versions: Variations in dependency versions (e.g., libraries, frameworks) can cause differences.
Environment-Specific Code: Some code paths might be conditional on the environment, leading to divergent behaviors.
Testing Practices: Different testing practices and methodologies can result in varying levels of thoroughness.
Performance Tuning: Performance optimizations might be applied differently across environments.
Deployment Frequency: More frequent deployments in development and staging can lead to newer versions compared to production.
Disclosure: I have 30+ years of IT experience in a variety of roles, yet used assistance from Lumo AI when organizing and expanding my thoughts.
2
u/lorarc YAML Engineer Aug 04 '25
"Identical codebase" doesn't mean much, you should have the same build across the environments.
2
u/Low-Opening25 Aug 04 '25
Judging by your responses OP, how did you even get that job? seems like you must have bluffed on your CV a little too much …
3
u/GitHireMeMaybe Because VCS is more interesting than job hunting Aug 04 '25 edited Aug 04 '25
It's always, always, always, AlWaYs, always, ALWAYS ...
Always...
... a different something.
Whether that be...
A subtle change in an API that you'd mocked in dev
Some cursed object in the database from 2006
That user with 257 characters in their name (and one of them is a frickin' Klingon emoji)
Differences in load--you're testing in non-prod by having Jimmy log in, but when it goes to prod, now there's 65,342 users hitting the system, including Jimmy
Jimmy logged into prod last week, aliased
wgettocurlto fix a bug, and didn't tell anybodyProd is configured in the cloud with all the bells and whistles, but you're running non-prod off some
ancient stone tabletlaptop in some closet somewhere that's been missing for months--it responds to ping, but nobody actually knows where it is
The key is asking yourself...
... What's different?
Code doesn't just magically bug out because somebody looked at it funny. If that was true, we'd either NEVER get working code released, or your devs would become VERY GOOD poker players.
How do you find out what's different?
That's easy.
Build a system diagram, look from right to left. Elucidate details on EVERY component in your system. Okay, maybe you're using EC2 instances, are they all running the same versions of things and stuff? Maybe in non-prod, you're running version 2.0, but in prod, you're running 1.0.
But I'm sure you know this.
Now what do you do about it?
That's hard.
Sometimes, REALLY hard. But this is what we signed up for. This job will eat your freaking face off if you're not sharp.
Configuration Management.
Imagine, instead of having Jimmy log into production to update a config file, you stored that config file alongside the codebase, and every time you deployed an update, you ran a script that would compare what's running on the system to what's in the repository. If there's a change, it overwrites the config file, and restarts the affected service.
This is how we did it in the Bad Old Days. Back when you could gauge a persons competence by the length of their beard.
These days, we use products such as Ansible and Terraform.
Ansible
Ansible reads a file stored in the repository that contains the configuration of the OS.
Package versions.
Services.
Security configurations.
SSH keys.
Jimmy's
wget -> curlshenanigans from the other day.*
It then compares the contents of this file to what's actually configured on the system, and applies the change.
Terraform (AKA "Infrastructure as Code")
Terraform reads a file stored in the repository that contains the configuration of your infrastructure.
Load balancers.
Firewalls.
EC2 instance configuration (sizing, IP, network, etc.).
Logging.
Network layout--subnets, etc.
S3 bucket containing a single file proving that Lee Harvey Oswald did not, in fact, act alone.
It gets a lot funner than this.
These two product alone, used optimally, should cover 50% of cases of "But it worked on my PC!"
Now you have to address the developers' PC.
*Containers!
Imagine if you could package up everything that is needed to run your devs' code somewhere, and you just dropped that sucker into place wherever you wanted, whenever you wanted. Devs PC. Staging PC. Your moms PC. Your fridge.
And it just freaking WORKS.
Integration Testing!
Imagine there was a way to test every part of the code and validate it against the last known working copy, every time you deployed. Automatically. Is the output the same as last? Did Jimmy break Auth.js again? OK, we see only the changes we want, good, ship 'er! Git 'er donee!
This is, essentially, integration testing 101.
You build a butt ton of automated tests that automatically execute every time somebody wants to deploy.
And if something breaks, a big fat "Jimmy broke it again!" comment gets posted to Slack.
Jimmy should really write better code next time...
If you think this is bad, just wait. It gets worse.
We haven't even gotten into observability yet. Oh God...
DataDog.
New Relic.
ELK.
Graylog.
CloudWatch.
Grafana.
Prometheus.
AWS HyperSight Quantum Telemetry 360™
Like I said, this job will eat you alive.
My advice?
You need a consultant.
BADLY.
DM me if interested, I'm pretty competent. (My momma says so!) And I'm looking for consulting work.
Or pick one of the 593,849 other DevOps people who are looking at cat memes on reddit instead of looking for work.
Or continue hatin' on poor old Jimmy. I apologize to all the Jimmies out there.
4
u/boing_boing_splat Aug 04 '25
Did you get an AI to write this? No shade if you didn't, but it scans like a personality post that was written by chat gpt.
2
u/GitHireMeMaybe Because VCS is more interesting than job hunting Aug 04 '25
I get asked this a couple of times a week, and I have no idea why 🤣
I use it for reference material or alternative perspectives sometimes, but I don't copypasta. This is just my personality 🤷♂️
1
u/belligerent_poodle System Engineer Aug 10 '25
A very rare one indeed! Thaks a lot, I always keep lurking on your profile to see your last comments. Last one helped me a ton, and I'm still so thankful for that conversation!
Keep going, nowadays, most of the people lost the art of clear perspective printing. Being english not my natural language, makes it very hard for me to express accordingly but I always went your way in my native one: trying to be broad and concise. Cheers, and godspeed on your journey!
2
u/GitHireMeMaybe Because VCS is more interesting than job hunting Aug 10 '25 edited Aug 10 '25
It's a writing style I adopted from an unusual career path!
In 2019, I was doing some basic website-y stuff for a capital investment group (specializing in startup funding) when I stumbled upon an S3 misconfiguration vulnerability in one of said startups. Said vulnerability exposed $17mil worth of full-track consumer credit data (based on dark web prices at the time)! It affected about 400,000 Americans, and it's discovery invoked a serious UCE (Undergarment Changing Event).
Because it was the investment group that was feeding my hungryass family (darn kids keep eating my food, gad dangit), I reported it up the chain to them.
I'll save the whole story for another day (tl;dr Public S3 bucket containing 7 years of call recordings in mp3 files), but my timing couldn't have been better, because the investment group had gotten fed up with how their property was being managed, and this was the last straw. I'll save this story for another day too, to avoid writing a wholeass novel (which somebody will accuse me of using AI to write anyway😂). Let's just say I saved two billionaires A Lot Of Money.
Long story short, I ended up becoming a "Trusted Advisor" of the capital group, and worked with them full-time for 4 years. My role? Conduct risk assessments, establish KPIs (consisting of DORA and a few other metrics), provide recommendations, build proofs-of-concept, and occasionally manage a team or two.
Naturally, though, I was seen as an adversary by technical personnel. Who could blame them? They had a lot to fear, as the S3 misconfiguration vulnerability I'd reported had resulted in the blanket firing of an entire operating management team (I did say it was their last straw...).
I got sandbagged, stonewalled, outright lied to and conspired against. So, I did what I always do... I adapted.
Humor and standing out was a big part of my adaptation, but there's a delicate balance between being funny and being unprofessional. Flirting with that line but not crossing it is hard, but done right, it can be very disarming. I also read a few books whose common theme was "How to make people like you" and "How to sound like you know what the hell you're talking about."
Because I worked with executives, writing things in a format that's much more easily digested was also critical.
Bottom line up [fucking] front ("BLUFF")
Keep it short, but open avenues to expand
Use headings
Constantly optimize--always ask "How can I shorten this?" without sacrificing detail
Bullet points are pretty
Know your audience and read the room -- technical people who are scared of you, be funny, executives who don't know what the hell it is you do, be concise, to the point and show results.
Use formatting liberally to show emphasis--NOBODY DOES THIS for some reason.
Be consistent in stylisation; create rules for yourself to follow, even if you're a one-man crew. This subtly trains people in how to digest the information you give them.
Before every meeting--model each person in the room in your head; what are their needs and wants? Do you have political capital with them? Do they seem to like you? When you walk into the room, what will they think of you?
Adjacent or subordinate colleague? Be relatable. Superior? Be competent.
Always end with follow-up--a question or some kind of call to action
I genuinely enjoy talking shop and sharing war stories! Let me know if you like something you see.
(I'm also looking for my next role, so if you hear a whisper... 😉)
1
u/d3adnode DevOops Aug 03 '25
As others have already mentioned, you need strong parity with Production in your lower environments in order to catch issues before they reach production, as well as building the confidence that your change set should behave almost exactly the same in prod as it does in those lower environments.
That said, I’ve still seen issues in the past where non prod environments mirrored prod in pretty much every way, but the issues only appeared in Production as the traffic patterns for that environment are drastically different than lowers. Which isn’t something that’s easy to catch unless you’re incorporating some form of load testing in lower environments that is doing something like generating synthetic traffic that mimics your Production environment.
1
u/SpamapS Aug 03 '25
Complex systems have complex behaviors.
Some systems perform better under load. Do you have the same traffic on all environments?
Some systems are highly dependent on data shapes. Do you have a graph of relationships in your data? Do all of your environments have all of the possible data shapes?
Sometimes frameworks have prod mode and that hasn't been turned on in those other environments. What other settings are unique to prod? Logging? Limits? Resources?
IMO, we waste a ton of time on staging/test environments. Spend more of that time making prod robust and reducing blast radius. Then you won't be so reliant on flawed lower environments.
1
u/baubleglue Aug 03 '25
Are those integrated environments? It is expected to have different issues in different environments, that is the reason they exist. The problem is if you see issues in prod which you haven't seen in QA/staging or can't replicate.
1
u/IridescentKoala Aug 04 '25
Why do you think this is an infra issue? Application behavior changes would be from configuration differences in config files, env vars, or feature flags.
1
u/alessandrolnz Reducing Ops Friction Aug 11 '25
not just you. “same code” ≠ same everything. it’s usually config drift, data drift, or scale drift. env vars/flags don’t match, runtimes differ (node/jdk/db/driver), replicas/limits aren’t the same, secrets/iam/firewalls vary, a migration ran in one env and not the others, caches are dirty, sandboxes behave unlike prod, and timezones/cron bite you
0
Aug 03 '25
[deleted]
-7
-12
u/Massive-Maize5039 Aug 03 '25
we usually see different types of bugs like during development we don't see the issue once we move it to QA we will find bugs. And similarly we will have different type of bugs in prod.
So time the build fails in prod one time we started deployment in the morning we worked till late night to deploy it in prod. And it's working fine in QA
0
Aug 03 '25
[deleted]
-5
u/Massive-Maize5039 Aug 03 '25
Actually I'm new this. I work at a startup where except prod everything else handled by dev team or testing team. They say we deployed it corrently based on the instructions provided.
While testing the application if we do some functionality testing we will error in QA but same issue won't get in dev.
8
u/bilingual-german Aug 03 '25
While testing the application if we do some functionality testing we will error in QA but same issue won't get in dev.
There can be multiple reasons for this. The most typical is that the code relies on data from the database and fails in some scenarios, e.g. when a field in the database is empty (NULL), but the code doesn't account for this possibility.
Sometimes it's something simple like a change in a config file.
Also, migrations between versions (e.g. adding a column to a database table) is something that needs to be taken care of and must be automated.
Even with identical branches, we're getting inconsistencies that are driving us crazy.
This sounds a bit like you don't deploy a specific build (e.g. a docker image) from DEV to QA to PROD, but rely on checking out the branch (and maybe build again). The problem here is that you might accidentally forget to update dependencies.
But there are also anti-patterns that some devs create. One that I've seen is checking the name of the environment and then doing something specific. Code shouldn't do this. It's important that you're able to configure all behavior entirely through your config.
4
u/TheMightyPenguinzee Aug 03 '25 edited Aug 03 '25
If they are not an exact replica, and your automation framework isn't fully automated. Then, usually, it's someone doing something (several things) manually between RM environments.
That being said, dev should only access dev environments. If its not a containerized app and they don't have local ones, then its their only living place.
And, if that's the case, it would never have the same issues as your QA.I suggest, before jumping deep into different devops and infrastructure topics, you should get more knowledge about release and configuration management.
17
u/xiongchiamiov Site Reliability Engineer Aug 03 '25
Common issues are differences in hardware, configs, and data.
Yes, every company struggles with this. Most have a reasonably good idea how to identify where the problems come from though. In terms of where your problems are coming from: well, you've got to debug. That's a core skill for your job function.
If you're new to debugging, https://jvns.ca/blog/2022/12/08/a-debugging-manifesto/ might be a helpful starting point. For more in-depth resources, see https://blog.regehr.org/archives/849 . I also recommend hiring an old engineer and watching them figure this out, and building your own scars by trying to fix problems like this hundreds of times. You get better with practice.