Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Article: Mutilple environments #295

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added files/Multiple_Environments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions practices/multiple_environments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
slug: multiple-environments
stages:
- development
short_description: Multi-environment usage is a recommended practice for software development as it helps in maintaining an optimal workflow for the project which overall helps in delivering the project in a reliable and timely manner.
tags:
- continuous integration
- continuous delivery
- software development
- quality control
- development environment
- testing environment
- staging environment
- production environment
- performance testing
- continuous integration
- revision control
keywords:
- continuous integration
- continuous delivery
- effective deployment
- load testing
- devops
- git
- testing
- testing environment
- staging environment
- production environment
- continuous integration
---

# Multiple Environments

**TL;DR**

Multi-environment usage is a recommended practice for software development as it helps in maintaining an optimal workflow for the project which overall helps in delivering the project in a reliable and timely manner. This structured release management process allows rollout, testing, and rollback in case of problems.

## What Is a Multi Environments

Multi-environment is a recommended practice that allows you to ship code to the end-user without any bugs or issues. This type of practice is very reliable as it involves multiple stages or environments. It also helps the company to reply to the user's feedback efficiently and immediately.

These environments are divided according to the tiers of the project. A particular individual related to a specific environment may not have access to other environments to avoid security breaches or human errors.

We can classify Multi-environments into different stages, according to the level of development across environments:

1. **Development environment**
The development environment (dev) is the environment in which software changes are developed, most simply an individual developer's workstation. This environment includes development tools like a compiler, integrated development environment, different or additional versions of libraries and support software, etc., which are not present in a user's environment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite this using your own words. It is too similar to the Wiki article: The development environment (dev) is the environment in which changes to software are developed, most simply an individual developer's workstation. This (..) environment will include development tools like a compiler, integrated development environment, different or additional versions of libraries and support software, etc., which are not present in a user's environment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, the Henricodofin article has text with similarities: The development environment is the environment in which changes to software are developed, most simply an individual developer's workstation. This differs from the ultimate target environment in various ways – the target may not be a desktop computer (it may be a smartphone, embedded system, headless machine in a data center, etc.), and even if otherwise similar, the developer's environment will include development tools like a compiler, integrated development environment, different or additional versions of libraries and support software, etc., which are not present in a user's environment.

A developer working on this environment has a working copy of source code on their machine, and changes are submitted to the repository, being committed either to the trunk or a branch, depending on development methodology. The environment on an individual workstation, in which changes are worked on and tried out, may be referred to as the local environment or a sandbox.
2. **Testing environment**
The purpose of the test environment is to allow human testers to exercise new and changed code via either automated checks or non-automated techniques. After the developer accepts the new code and configurations through unit testing in the development environment, the items are moved to one or more test environments. Upon test failure, the test environment can remove the faulty code from the test platforms, contact the responsible developer, and provide detailed test and result logs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite this with your own words, too similar sentences can be found in the Wiki article:

The purpose of the test environment is to allow human testers to exercise new and changed code via either automated checks or non-automated techniques. After the developer accepts the new code and configurations through unit testing in the development environment, the items are moved to one or more test environments. Upon test failure, the test environment can remove the faulty code from the test platforms, contact the responsible developer, and provide detailed test and result logs.

If all tests pass, the test environment or a continuous integration framework controlling the tests can automatically promote the code to the next deployment environment.

If all tests pass, the test environment or a continuous integration framework controlling the tests can automatically promote the code to the next deployment environment.
3. **Staging environment**
The staging environment or pre-production environment is an environment for testing that exactly resembles a production environment. It seeks to mirror an actual production environment as closely as possible and may connect to other production services and data, such as databases.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, this senction too closely follows the original text from Wiki:

A stage, staging or pre-production environment is an environment for testing that exactly resembles a production environment.[7] It seeks to mirror an actual production environment as closely as possible and may connect to other production services and data, such as databases. For example, servers will be run on remote machines, rather than locally (as on a developer's workstation during dev, or on a single test machine during test), which tests the effects of networking on the system.

The primary use of a staging environment is to test all the installation/configuration/migration scripts and procedures before they're applied to a production environment. This ensures all major and minor upgrades to a production environment are completed reliably, without errors, and in a minimum of time.

Another important use of staging is performance testing, particularly load testing, as this is often sensitive to the environment.

Staging is also used by some organizations to preview new features to select customers or to validate integrations with live versions of external dependencies.

The primary use of a staging environment is to test all the installation/configuration/migration scripts and procedures before they're applied to a production environment. This ensures all major and minor upgrades to a production environment are completed reliably, without errors, and in a minimum of time.
Another important use of staging is performance testing, particularly load testing, as this is often sensitive to the environment.
Staging environmet is also used by some organizations to preview new features to select customers or to validate integrations with live versions of external dependencies.
3. **Production environment**
The production environment can also be said as a live environment, particularly for servers, as it is the environment that users directly interact with. Deploying to production is the most sensitive step; it may be done by deploying new code directly, or by deploying a configuration change.
Deploying a new release generally requires a restart, unless hot swapping is possible, and thus requires either an interruption in service (usual for user software, where applications are restarted) or redundancy – either restarting instances slowly behind a load balancer or starting up new servers ahead of time and then simply redirecting traffic to the new servers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite this part as well. I see similarities with the WIki article, mainly in these parts:

The production environment is also known as live, particularly for servers, as it is the environment that users directly interact with. Deploying to production is the most sensitive step; it may be done by deploying ... a configuration change; deploying

Deploying a new release generally requires a restart, unless hot swapping is possible, and thus requires either an interruption in service (usual for user software, where applications are restarted) or redundancy – either restarting instances slowly behind a load balancer or starting up new servers ahead of time and then simply redirecting traffic to the new servers.



![Multiple Environments](/files/Multiple_Environments.png)</br>
Source: [Using Multiple Environments to Improve Your Development Workflow](https://deploybot.com/blog/using-multiple-environments-to-improve-your-development-workflow)

## Why Use Multi Environments

Multi Environments helps you with:

- **Keeps the team productive**
Having multiple environments enables a team to work on parallel development efforts. If there are several people working on the app, using a different environment for each group of people helps keep the team productive.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite this with your own words, it is too similar to the original:

Having multiple environments enables a team to work on parallel development efforts. If there are several people working on the app, using a different environment for each group of people helps keep the team productive.

- **It reduces or eliminates downtime and thus saves the company from loss of revenue**
Thoroughly testing software through multiple environments allows you to deliver a product to your users that is just as reliable and dependable as your company. If the software directly deals with the exchange of money, errors in the code could also lead to losses.
- **Provides better security**
To protect the integrity of your production data, you should limit access to it. Team members should have clearly defined roles and access rights to different parts of the system. Having multiple environments makes this possible. If you have separate development and production environments, it prevents developers from accidentally messing with or deleting production data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, give this a second thought. It has similarities to the original:

To protect the integrity of your production data, you should limit access to it. Team members should have clearly defined roles and access rights to different parts of the system. Having multiple environments makes this possible. If you have separate development and production environments, it prevents developers from accidentally messing with or deleting production data

- **Saves time and helps in getting the product to the market faster**
Using multiple environments when developing software saves time as no one has to wait on another person for shared resources. Which will help in launching the product as soon as possible.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite the Using multiple environments when developing software saves time as no one has to wait on another person for shared resources, it is too similar to _Using multiple environments when developing software saves time as no one has to wait on another person for shared resources. _

- **Promotes innovation**
When you are working with multiple environments, your team is free to experiment on environments that are especially dedicated for this. Since there is no fear of messing with the live code, the team can use a separate environment to test out ideas and even deploy the code to a server where it can be made available to some test users who can give feedback on it, which the team can use to decide if they should implement the changes on the main codebase.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, rewrite this part with your own words. It is too similar to the original paragraph:
Using multiple environments promotes innovation: When you are working with multiple environments, your team is free to experiment on environments that are especially dedicated for this. Since there is no fear of messing with the live code, the team can use a separate environment to test out ideas and even deploy the code to a server where it can be made available to some test users who can give feedback on it, which the team can use to decide if they should implement the changes on the main codebase.

https://deploybot.com/blog/using-multiple-environments-to-improve-your-development-workflow


## Issues the Multi Environments Solves

- Human errors
- [Poor Code Quality](/problems/poor-code-quality)
- [Meaningless Work](/problems/meaningless-work)
- Developers vs. Operations wars
- Security Breaches
- [Long Feedback Loops](/problems/long-feedback-loops)

## How to Implement Multi Environment

Follow these steps to set up a basic Multi Environment pipeline:

1. **Set up a Continuous Integration server**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. **Set up a Continuous Integration server**
1. **Set up a [Continuous Integration](/practices/continuous-integration) server**

- Choose an existing server, such as [Jenkins](https://jenkins.io/), or [go.cd](https://www.gocd.org/).
- Set up your first build (a link to your source code, for example, on GitHub and a command to build the application)
- Ensure that it runs every time a change is checked into source control.
2. **Enable Multi-Environment support**
- **With GitFlow**
- In this approach, you can use the structure [GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) provides. However, it will require your team to understand [GitFlow](/practices/git_flow).
- Here is the outline:
| Branch | Environment to Deploy |
|--------------------|-----------------------|
|feature/**, develop | dev |
|release/** | staging |
|master | production |
- **Without GitFlow**
- This approach simply ties a specific branch to a specific firebase project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- This approach simply ties a specific branch to a specific firebase project.
- This approach connects a specific branch with a specific environment.

Firebase is one of many platforms. The original article spoke about it because the article is about Firebase. In our case, there is no specification (and using the name of a specific platform can look confusing

- Here is the outline:
| Branch | Environment to Deploy |
|--------------------|-----------------------|
|develop | dev |
|staging | staging |
|master | production |

## Common Pitfalls of the Multi Environment

- Exaggerated reliance on the Multi Environment
- Can be time-consuming
- Rigid pipeline design

## Resources for the Multi Environment

- Deploybot blogs: [Using Multiple Environments to Improve Your Development Workflow](https://deploybot.com/blog/using-multiple-environments-to-improve-your-development-workflow)
- [Multi-Environment deployment for a React App](https://medium.com/@giologist/ci-cd-multi-environment-deployment-for-a-react-app-on-firebase-using-github-actions-f48bc6b08b21)
- [Deployment environment](https://en.wikipedia.org/wiki/Deployment_environment)