Apps & Software
Staging and Production: Separating Internal App Environments
Testing changes directly on the application staff are using can be costly. This guide explains what must match and what must stay separate between staging and production.
SEO and Content Specialist
6 min read
Short answer: a staging environment is a copy of production used to test changes before users get them. Keep the type and version of the database and supporting services, the base configuration, and the release method the same. Separate credentials, databases, secrets, connections to outside services, and access rights. Avoid real data in staging, and if it must be used, approve it, record it, and protect it as you would in production.
Internal applications often start life on a single server. A developer tries a fix right there while staff are using it, and one small table change leaves the monthly report unable to open. Separating environments solves that, but only when the separation is done properly: staging that differs too much gives false confidence, while staging that is too tied to production can damage real data.
What is a staging environment and how does it differ from production?
An environment is a complete set where an application runs: code, servers, database, configuration, and connections to other services. Three are usually enough for an internal application.
| Aspect | Development | Staging | Production |
|---|---|---|---|
| Users | Developers | Testers and user representatives | All users |
| Purpose | Write and try code | Prove a release is ready | Do real work |
| Data | Sample data | Test data or masked data | Real data |
| Changes | Any time | Through the release flow | Through the release flow and approval |
| If it breaks | Developers fix it | Release is held | Work is disrupted |
NIST SP 800-53 Revision 5, in control CM-4(1), asks for changes to be analysed in a separate test environment before they are implemented in the operational one. Separation may be physical or logical, as long as test activity does not affect operations and operational information does not flow there by accident. So two properly restricted virtual machines can be enough, provided the boundary is defined and checked.
What must be the same?
The closer staging is to production, the more its test results mean. The Twelve-Factor App methodology advises keeping development, staging, and production as similar as possible, including the same type and version of backing services such as databases, queues, and caches. The reason is that small incompatibilities can make code that passed testing fail in production. Using SQLite in development and PostgreSQL in production is one example it gives.
OWASP Top 10:2025, in the Security Misconfiguration category, advises configuring development, QA, and production environments identically, with different credentials in each. Things worth keeping identical:
- Operating system, runtime, and library versions.
- Database and supporting service types and versions.
- Web server settings, time zone, and upload size limits.
- The release method, including database schema change scripts.
- Security rules, such as HTTPS and user roles.
Server size may be smaller. Record that difference, because performance tests on a small machine do not automatically represent production. Keeping configuration as code helps stop the two from drifting apart.
What must be separated?
What differs between environments is anything that can touch real data or real parties. Twelve-Factor defines config as whatever varies between deploys, such as database addresses, outside service credentials, and host names, then asks for all of it to be kept apart from code and recommends environment variables.
Take care with secrets such as passwords and API keys. The OWASP Secrets Management Cheat Sheet, in its discussion of containers, notes that environment variables are generally accessible to all processes and may end up in logs or memory dumps, so other methods, such as a secrets manager, are preferred where available.
| What to separate | Risk if shared |
|---|---|
| Database and file storage | Tests change or delete real data |
| Credentials and API keys | A leak in staging opens production |
| Email, messages, and notifications | Staff or customers receive test messages |
| Payments and outside integrations | Test transactions reach real systems |
| Scheduled jobs | A process runs twice on the same data |
| Accounts and access rights | People who only need to test also hold production access |
Staging access needs limits too. An address open to the internet with a sample password is a door rarely watched. Add authentication, restrict it through a VPN or an allow list, and patch it like any other server.
How should staging data be handled?
The safest choice is generated test data. NIST SP 800-53, in control SA-3(2), notes that using operational data in preproduction environments can create significant risk, which can be reduced with test or dummy data. If real data is still used, the control asks for its use to be approved, documented, and controlled, and for the environment to be protected at the same level as that data.
If the data includes personal data, Article 16 paragraph (2) of Law Number 27 of 2022 on Personal Data Protection sets principles to observe, including processing in line with its purpose and protection against unauthorised access and disclosure. Check how it applies with a legal adviser. Technically, a sensible order of options is:
- Create sample data that mimics the shape, volume, and difficult cases of real data.
- If real patterns are needed, copy only a portion, then mask names, identity numbers, contacts, and sensitive values before it enters staging.
- If real data cannot be avoided, get written approval, restrict access, and delete it once testing ends.
From staging to production: who approves?
The build tested in staging should be the same one installed in production, with only configuration differing. A simple flow: code is merged, tested automatically, deployed to staging, checked, approved, then deployed to production. The automation is covered in What Is CI/CD, and involving users in Testing Internal Applications with Staff.
Common tools already support this idea. GitHub Actions offers deployment environments that can require approval, restrict branches, and hold secrets per environment. Availability depends on the plan: according to GitHub documentation, required reviewers on Free, Pro, and Team plans apply only to public repositories. GitLab offers protected environments to restrict who may deploy in its Premium and Ultimate tiers. Check your plan before designing the flow.
Before a release, confirm that:
- Automated tests pass on the version to be installed.
- Database schema changes have been tried in staging.
- Production configuration and secrets are in place.
- The approver and release schedule are recorded.
- The way back to the previous version is written down.
How Legia does it
In the DevOps & CI/CD service, Legia aligns test and production environments through containerisation and infrastructure as code, builds an automated release pipeline, and sets up monitoring and version rollback. Vulnerability scanning and key and secret management are part of the release flow, with access set per role. Configuration is stored as code in your repository. The whole process from mapping to handover takes about 9 to 15 weeks. Other services are on the Applications & Software page.
Frequently asked questions
Does a small application need staging?
Yes, if an outage stops work or the data is hard to recover. It can be simple, as long as its database and credentials are separate from production.
Can staging and production share one server?
It can work as logical separation, but they share resources and a point of failure. A test that loads the machine can disrupt users, so resource and access limits must be strict.
When should staging data be refreshed?
As testing requires, for example before a large release. Every refresh from production should pass through the same masking process, preferably automated.
Does passing staging mean a release is safe?
No. Load, data, and user behaviour in production can differ. That is why post-release monitoring and a way to roll back are still needed.
Sources
- The Twelve-Factor App, Dev/prod parity12factor.net
- The Twelve-Factor App, Config12factor.net
- OWASP Top 10:2025, A02 Security Misconfigurationtop10.owasp.org
- OWASP, Secrets Management Cheat Sheetcheatsheetseries.owasp.org
- NIST, SP 800-53 Rev. 5 Security and Privacy Controlsnvlpubs.nist.gov
- GitHub Docs, Deployments and environmentsdocs.github.com
- GitLab Docs, Protected environmentsdocs.gitlab.com
- Text of Article 16, Law 27/2022pasal.id

