0% found this document useful (0 votes)
135 views22 pages

Blue Green Deployment

This document provides an in-depth overview of Blue/Green Deployment, a popular deployment strategy designed to minimize risks and downtime during application updates. It explains the principles, advantages, and real-world examples of its implementation, including practical tips for using Blue/Green Deployment with AWS services. The report also compares Blue/Green Deployment with other deployment methods like Canary, Rolling, and Highlander.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views22 pages

Blue Green Deployment

This document provides an in-depth overview of Blue/Green Deployment, a popular deployment strategy designed to minimize risks and downtime during application updates. It explains the principles, advantages, and real-world examples of its implementation, including practical tips for using Blue/Green Deployment with AWS services. The report also compares Blue/Green Deployment with other deployment methods like Canary, Rolling, and Highlander.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Anton Alputov

BLUE/GREEN
DEPLOYMENT

© Valletta Software Development 2024


Good day, dear colleagues. Today, I am pleased to
present a report on the topic of Blue/Green Deployment.
This deployment method is becoming increasingly
popular due to its advantages and its ability to minimize
risks when releasing new application versions.
Today, we will explore the principles behind this method,
its benefits, and real-world use cases, including my
experience with migrating production and development
environments in AWS with seamless data replication.
Our goal is to demonstrate how Blue/Green Deployment
can help you improve the deployment process, making it
more secure and reliable. Let's get started!
LOAD
BALANCE

USERS

Let's take a closer look at how Blue/Green Deployment


works. The core principle is to divide the infrastructure
into two identical environments: Blue and Green. Blue is
the current production environment that handles all user
requests, while Green is the environment where we
deploy the new version of our application.
The process begins by deploying the new version of the
application in the Green environment. It's important to
note that the Green environment is identical to Blue,
except for the version of the application. This allows us
to conduct all necessary testing and ensure that the new
version functions correctly.
After successful testing, we begin the process of
switching traffic from the Blue environment to the Green
environment. This can be done in various ways, such as
modifying DNS settings or using a load balancer. As a
result, the Green environment becomes the new
production environment, while the Blue environment
serves as a backup.
One of the key advantages of Blue/Green Deployment is
the minimization of downtime. The switch happens
almost instantly, and users are unaware of the update
process.
This method also allows for easy rollback to the previous
version.
If any issues arise with the new version, we simply
redirect the traffic back to the Blue environment.
Now, let's look at the specific advantages that
Blue/Green Deployment offers. This deployment method
provides several key benefits that make it appealing to
many organizations:
1. Minimized downtime.
2. Easy rollback.
3. A/B testing support.
4. Shorter MTTR time.
1. Minimized downtime
Firstly, minimizing downtime risk. Since we always have
a backup environment to revert to in case any issues
arise, we significantly reduce the risk associated with
releasing new versions.

This is especially important for mission-critical


applications, where even a small failure can lead to
serious consequences.
2. Easy rollback
Secondly, ease of rollback. If the new version causes
issues, we can quickly and easily redirect traffic back to
the previous version, ensuring minimal downtime for
users.

This swift transition helps maintain service availability


and reduces the impact of potential errors.
3. A/B testing support
The third advantage is the ability to conduct A/B testing.
Since we have two identical environments, we can route
a portion of the traffic to the new version and assess its
performance and stability in real-world conditions before
fully switching over.

This allows for data-driven decisions and reduces the


risk of unforeseen issues when deploying the new
version to all users.
4. Shorter MTTR time
Lastly, Blue/Green Deployment significantly improves
recovery time in the event of incidents. Since the backup
environment is always ready for use, we can quickly
restore the application's functionality.

As you can see, this deployment method offers


numerous benefits that make the deployment process
safer and more reliable.
Migration to AWS AWS CDK v2
Now, let's move on to a real-world example of Blue/Green
Deployment from my own experience. Recently, we had
to migrate AWS CDK to its second version, as well as
move both production and development environments in
AWS from one account to other accounts.

This process involved a significant update to the entire


codebase and architecture. Due to the monorepo
structure, it was difficult to migrate service by service,
and this migration included deploying all necessary
services on the new accounts, replicating data, and
seamlessly switching traffic.
Migration to AWS AWS CDK v2
I started by preparing the Green environment on the new
AWS account. This involved deploying all the necessary
services, such as the database, Kafka, ECS clusters,
networking components, and other AWS services. I also
set up synchronization of S3 buckets, database
replication, and mirroring of Kafka brokers between the
old (Blue) and new (Green) environments to ensure data
consistency at the moment of the switch.

Once the Green environment was fully ready and tested,


we began the process of switching the traffic.
Migration to AWS AWS CDK v2
We used Route 53 to modify the NS records, which
allowed us to redirect all user requests from the Blue
environment to the Green environment almost instantly,
minimizing downtime. I applied this approach for each
environment, migrating them to separate accounts.
As a result, the migration was seamless, with no
noticeable interruption in service for users. This allowed
us to successfully update the infrastructure and move to
new AWS accounts without any negative impact.
This example clearly demonstrates how Blue/Green
Deployment can be effectively used for safe and efficient
migration between accounts.
Blue/Green Deployment implementation
using various AWS services

1. Amazon ECS:
In Amazon ECS, you can easily set up two identical task
groups: one representing the Blue environment and the
other the Green. After deploying a new version in the
Green environment, traffic can be switched using a load
balancer.
In this case, we use the same load balancer but with two
listener rules that listen on different ports: 8080 for Blue
and 80 for Green.
The deployment completes by switching listener rules
between the two target groups, ensuring a quick and safe
transition to the new version. If issues arise, it's easy to
revert back to the previous version by reassigning traffic.
2. AWS Elastic Beanstalk:
Elastic Beanstalk has built-in Blue/Green Deployment
support. You can deploy a new version of your
application in the Green environment, test it, and then
switch traffic using the "Swap environment URLs"
feature.
This simply swaps the CNAME records of the old and
new environments, effectively redirecting traffic from the
old version to the new one. This approach is similar to
the account migration example I shared earlier.
3. AWS Lambda with Application Load Balancer and
Weighted Target Groups:
In this scenario, you create two versions of a Lambda
function: Blue and Green. Each function version is tied to
a separate target group in an Application Load Balancer
(ALB).
You can gradually shift traffic from the Blue version to
the Green by adjusting the weighted values of the target
groups. Alternatively, you can instantly switch all traffic
by setting one version's weight to 0% and the other's to
100%.
Canary Deployment:
Process: A small percentage of traffic is gradually routed
to the new version (canary), while the rest continues
using the old version. If no issues are detected, the
canary version progressively receives more traffic until
100% is switched over.
Benefits: Allows for gradual testing of the new version
with live users. Reduces the risk of wide-scale failures by
exposing only a portion of users to the new version
initially.
Drawbacks: Slower to fully deploy, as it requires
monitoring at each stage. Rollback is more complex than
Blue/Green if issues are detected late in the process.
Rolling Deployment:
Process: The new version is deployed incrementally
across the infrastructure, replacing old instances one at
a time. During the process, both the old and new
versions may be live at the same time.
Benefits: No need for duplicate environments, so it’s
cost-effective. Suitable for large-scale applications
where deployments can be handled in smaller batches.
Drawbacks: Can introduce inconsistency, as different
users might see different versions during the
deployment. Rollback can be slow and complicated if
issues arise after partial deployment.
A/B Testing Deployment:
Process: Similar to Blue/Green, but with a focus on
testing different features or versions (A and B) for
comparison. Users are split between the two
environments to evaluate performance, user experience,
or new features.
Benefits: Provides insights into user behavior and
performance differences between versions. Allows for
data-driven decisions based on real-time feedback.
Drawbacks: May require long-running parallel
environments, increasing costs. Not ideal for critical
application updates where one version must fully replace
the other.
Highlander Deployment:
Process: The new version of the application is deployed
across all servers simultaneously. The old version is
entirely removed, and only the new one remains active.
Benefits: There is no need for duplicate infrastructure,
as only one environment is maintained. With no need to
maintain two separate environments (Blue and Green),
infrastructure costs are lower.
Drawbacks: If the new version has issues, all users will
experience problems simultaneously, with no quick
rollback option. There is no opportunity to test the new
version in a live environment before deployment.
2. Monitoring
and Testing

1. Planning
and Preparation

Let's summarize and go over a few recommendations for


implementing Blue/Green Deployment in your projects. I
recommend the following steps:
1. Planning and Preparation:
Ensure you have a clear migration plan and sufficient
resources to support both the Blue and Green
environments. Prepare and thoroughly test the Green
environment before switching traffic.
2. Monitoring and Testing:
Use monitoring tools to track the performance and
stability of the new version. Conduct comprehensive
testing in the Green environment to ensure there are no
critical errors before moving to production.
3. Automation

4. Documentation
and Training

3. Automation:
Implement automated deployment and traffic switching
processes to minimize human error and speed up the
migration process. This will enhance the reliability and
efficiency of your deployment.
4. Documentation and Training:
Train your team on Blue/Green Deployment techniques
and prepare detailed documentation to streamline the
deployment and rollback processes. Clear guidelines will
make the process smoother and ensure everyone is
aligned.
Thank you for your time!
https://www.linkedin.com/in/alputov/
Anton Alputov is a mature IT professional
offering 14 years of hands-on experience in
the Web industry. Strong knowledge of Java
8-17. Deep knowledge and versatile
experience in DevOps, building interactive
Web applications onRESTful
Spring framework (Core, MVC, Data, Security)
and Spring Boot.
I can write SQL queries and have excellent experience in database
normalization and optimization. I love writing unit and integration
tests. I guarantee clean code,
adherence to SOLID and OOP design
patterns. On the last project, I
actively worked with microservice
architecture on Spring Cloud.

© Valletta Software Development 2024

You might also like