There are several prevalent deployment strategies – Canary, Blue/Green, and Rolling – each with their own strengths, weaknesses, and use-cases.

Table of Contents

Canary Deployment Strategy

In Canary deployments, a new version of the application is gradually rolled out to a small subset of users before being introduced to the entire infrastructure. If the canary version functions as expected with the test users, it is then provided to the rest of the user base. This strategy allows the team to test a new version of the application in the production environment under real-world conditions, but with a limited user base. This minimizes the potential impact of unforeseen issues.

Here is a high-level representation of how canary deployment works:

  1. Deploy the new version of application next to the old version.
  2. Forward a small percentage of traffic to the new version, while the rest goes to the old version.
  3. Monitor and analyse the new version.
  4. If everything is okay, gradually increase the traffic to the new version.
  5. If there’s a problem, roll back to the old version immediately.

shell
aws codedeploy create-deployment \
--application-name myApplicationName \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name myDeploymentGroupName \
--github-location repository=MyGitHubRepo,commitId=abc123

Blue/Green Deployment Strategy

In Blue/Green deployment, two production environments (blue and green) are maintained. The blue environment hosts the current version of the application, while the green environment is used to roll out the new version.

Once the new version is tested and ready for release, the load balancer switches traffic from the blue environment to the green environment, making the new version live. This type of deployment minimizes downtime and risk by providing a rapid rollback feature if needed.

Here is a high-level representation of how blue/green deployment works:

  1. Blue environment runs the live/old version, while the green environment prepares the new version.
  2. Once green is tested and verified, the load balancer shifts traffic to the green environment.
  3. Blue environment is now idle and can be used in future for the next rollout.

shell
aws ecs create-service --service-name my-service \
--task-definition my-task-set \
--load-balancer targetGroupArn=arn:aws:elasticloadbalancing:region:xxxxxxxx:targetgroup/my-targets/1234567890123456,containerName=my-app,containerPort=80 \
--platform-version 1.4.0 \
--deployment-configuration "maximumPercent=200,minimumHealthyPercent=100" \
--scheduling-strategy REPLICA \
--desired-count 1

Rolling Deployment Strategy

Rolling deployment refers to the process of gradually deploying updates across multiple servers or server groups. Instead of updating all servers simultaneously, the update hits a few servers at a time, minimizing the impact of a faulty update and reducing downtime.

Here is a high-level representation of how rolling deployment works:

  1. Prepare the new version of your application.
  2. Slowly roll out the update to a few instances at a time.
  3. If issues surface, you can stop the rollout and fix the issues.
  4. If everything runs smoothly, continue until all instances are updated.

shell
aws deploy create-deployment-group \
--application-name myApplication \
--auto-scaling-groups myAutoScalingGroup \
--deployment-group-name myDeploymentGroup \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--service-role-arn arn:aws:iam::123456789012:role/CodeDeployServiceRole

Comparison of Strategies

Deployment Strategy Pros Cons
Canary Reduced risk due to phased rollout; Real-world user testing Longer deployment times; Success depends on effective user segmentation
Blue/Green Rapid rollback; Minimized downtime during deployment Requires twice the number of environments; Resource heavy
Rolling No additional environments needed; Phased rollout reduces risk and minimizes downtime Slower deployment times; Rollback can be more complicated

Choosing which deployment strategy to use depends on your project’s requirements, the resources available, and your team’s comfort with handling potential issues during the deployment process.

Understanding these strategies can give you an edge in managing the ever-evolving landscape of deployments and system updates as an AWS developer.

Practice Test

True or False: Canary deployments allow for the rolling out of new functionalities to only subset of users.

  • True
  • False

Answer: True

Explanation: Canary deployments release the new version to a small subset of users, and once the new version is tested and declared stable, it is rolled out to all users.

Which of the following is not a deployment strategy?

  • a) Blue/Green
  • b) Canary
  • c) Rolling
  • d) Pink/Yellow

Answer: d) Pink/Yellow

Explanation: Pink/Yellow is not a recognized deployment strategy in AWS or otherwise. Blue/Green, Canary, and Rolling are all well-established strategies for different types of deployment scenarios.

True or False: With Blue/Green deployment strategy, the new version is released to all users at once.

  • True
  • False

Answer: True

Explanation: In Blue/Green deployment, two environments are maintained and the traffic is entirely switched from the old version (Blue) to the new version (Green) after testing.

Which of the following strategy involves no downtime during deployment?

  • a) Canary
  • b) Rolling
  • c) Blue/Green
  • d) All of the above

Answer: c) Blue/Green

Explanation: Blue/Green deployment strategy is designed to prevent any downtime as the switch from the Blue environment to the Green happens instantaneously.

True or False: AWS does not support Blue/Green deployment out of the box.

  • True
  • False

Answer: False

Explanation: AWS CodeDeploy supports Blue/Green deployment out of the box.

Which AWS service directly supports Canary releases?

  • a) AWS CodeDeploy
  • b) AWS S3
  • c) AWS Lambda
  • d) None of the above

Answer: c) AWS Lambda

Explanation: AWS Lambda supports Canary release deployment, which allows users to gradually shift customer traffic to the new version of the lambda function.

With the Rolling update strategy, is there a possibility of having two versions running simultaneously?

  • a) No, never
  • b) Yes, always
  • c) Only in case of errors
  • d) Only during Canary deployments

Answer: b) Yes, always

Explanation: Rolling update is performed by gradually replacing instances of the previous version of an application with the new version.

In Blue/Green deployments, what happens to the Green environment after successful deployment?

  • a) It is deleted
  • b) It becomes the new Blue environment
  • c) It continues to run alongside the Blue environment
  • d) It becomes the new Canary environment

Answer: b) It becomes the new Blue environment

Explanation: After successful deployment, the green environment (new version) becomes the blue environment (live/production) and the previous blue environment can be retained for backup or rollback.

Which deployment strategy is most suitable for big, critical applications where downtime cannot be tolerated?

  • a) Blue/Green
  • b) Canary
  • c) Rolling
  • d) All of the above

Answer: a) Blue/Green

Explanation: Blue/Green deployments are ideal for critical applications as they allow for testing in an identical clone of the production environment and immediate switch over without downtime.

In a Rolling deployment strategy, if an error occurs during the deployment process, are subsequent deployments halted?

  • a) Yes, always
  • b) No, never
  • c) Only in certain cases
  • d) It’s unpredictable

Answer: a) Yes, always

Explanation: In a Rolling deployment strategy, if an error is detected during the deployment, the process is stopped to prevent the error from affecting more instances.

Can Canary deployments be used to perform A/B Testing?

  • a) Yes
  • b) No

Answer: a) Yes

Explanation: Canary deployments can be effectively used for A/B testing as new functionalities are gradually rolled out to a subset of users, whose feedback can help decide the next course of action.

Which strategy provides the capability to rollback to the previous version in case of any disaster after the deployment?

  • a) Blue/Green
  • b) Canary
  • c) Rolling
  • d) All of the above

Answer: a) Blue/Green

Explanation: Blue/Green deployments keep the previous environment (Blue) intact until the new version (Green) is proven stable, hence allowing the capacity for a quicker disaster recovery or rollback if needed.

Interview Questions

What is a canary deployment strategy in AWS?

Canary deployment is a strategy where a set of users or servers are used to test new software versions before full deployment. In AWS, it can be implemented using AWS CodeDeploy where a small portion of the traffic is routed to the updated version of the application.

Can you outline the blue/green deployment strategy?

The blue/green deployment strategy involves maintaining two environments – ‘blue’ for the current live production environment and ‘green’ for the new version under test. Traffic is switched from the blue environment to the green environment only when the new version is fully ready.

What AWS service can you use to implement a rolling deployment strategy?

AWS Elastic Beanstalk supports rolling deployments, which allow an application to be updated in a staggered manner, limiting the impact of any issues with the update.

What is the main disadvantage of a rolling deployment?

The main disadvantage of a rolling deployment is that, because the deployment happens in stages, different users might experience different versions of the application during the update process.

What is the key advantage of a blue/green deployment strategy?

The key advantage of the blue/green deployment strategy is it reduces the downtime risk during deployments. It also allows developers to quickly rollback to the previous version if needed.

How does a canary deployment minimize the impact of bugs for users in AWS?

Canary deployment minimizes the impact of bugs by enabling developers to release the changes to a small set of users or resources. If any issues arise, they are limited to this subset and can be addressed before a full-scale rollout.

In a blue/green deployment, how is traffic switched between environments?

In AWS, traffic switching can be managed using AWS Route 53. By changing the DNS configuration in Route 53, you can perform the cut-over from the blue environment to the green one.

Which deployment strategy is the fastest to implement?

The Rolling deployment strategy is generally the fastest to implement as it gradually updates instances with the latest software versions.

Which AWS services enable you to use the Canary deployment strategy?

AWS CodeDeploy and AWS Lambda both support Canary deployment strategies.

How do you handle database migrations in a blue/green deployment strategy?

Database migrations can be challenging in this strategy. One approach is to make the database schema changes backwards-compatible, apply them before the switch-over, and then remove the obsolete parts once all the old instances are decommissioned.

How can you automate the blue/green deployment in AWS?

You can automate blue/green deployments using AWS CodeDeploy, combined with other AWS services like AWS Elastic Beanstalk, AWS Elastic Load Balancer, and AWS Route 53.

Explain the major difference between Canary and Blue/Green deployment strategies?

Canary deployment exposes a small portion of users to new software versions, whereas Blue/Green deployment involves creating a clone of your production environment (green) to deploy and test the newer version. User traffic is then switched from one environment to the other.

How do deployment strategies contribute to achieving zero-downtime deployments?

Deployment strategies like blue/green and canary allow for the testing of new software versions and the mitigation of any hurdles or bugs in those versions before full deployment, thus minimizing or avoiding downtime.

Which deployment strategy is most appropriate for large applications with many users?

The Blue/Green deployment strategy is generally suited for large applications as it gives a testing environment before switching traffic and avoids users experiencing different versions.

What AWS service can help minimize downtime during application updates?

AWS Elastic Beanstalk offers several deployment options to minimize downtime during application updates, including All at once, Rolling updates, and Rolling with additional batch.

Leave a Reply

Your email address will not be published. Required fields are marked *