liveBook · Manning

Rolling update

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

A rolling update replaces instances or software versions incrementally while keeping enough of the existing deployment available to avoid service interruption.

A rolling update replaces EC2 instances rather than changing software on running machines. AWS CloudFormation can orchestrate the replacement through an Auto Scaling group: launch a new instance from an updated launch template, run its deployment script, then terminate the old instance. This approach is intended to keep the application available during deployment. section 15.2 section 15.1

Use this pattern when instances are disposable: the application must not depend on data retained only on an instance’s local disk or in memory. Starting each deployment on a new machine avoids surprises caused by earlier changes to a long-running server. An Application Load Balancer forwards requests to the web application, while the Auto Scaling group manages its EC2 instances. section 15.2 section 15.1 section 15.0

To roll out an Etherpad version:

  • Deploy a CloudFormation stack with `EtherpadVersion=1.8.17`. Its launch template supplies user data that installs dependencies, fetches and configures Etherpad, and starts it. section 15.2
  • Change the version parameter to `EtherpadVersion=1.8.18` and deploy the stack again. CloudFormation updates the launch template and orchestrates replacement through the Auto Scaling group. section 15.2
  • Open the stack’s application URL to check the deployed version. If startup fails, inspect `/var/log/cloud-init-output.log` on the instance. section 15.2
Listing 15.5 Updating the Auto Scaling group or the referenced launch template
AutoScalingGroup:                                  #1
  Type: 'AWS::AutoScaling::AutoScalingGroup'
  Properties:
    TargetGroupARNs:
    - !Ref LoadBalancerTargetGroup
    LaunchTemplate:                                #2
      LaunchTemplateId: !Ref LaunchTemplate
      Version: !GetAtt 'LaunchTemplate.LatestVersionNumber'
    MinSize: '1'                                   #3
    MaxSize: '2'                                   #4
    HealthCheckGracePeriod: 300
    HealthCheckType: ELB
    VPCZoneIdentifier:
    - !Ref SubnetA
    - !Ref SubnetB
    Tags:
    - PropagateAtLaunch: true
      Value: etherpad
      Key: Name
  CreationPolicy:
    ResourceSignal:
      Timeout: PT10M
  UpdatePolicy:                                    #5
    AutoScalingRollingUpdate:                      #6
      PauseTime: PT10M                             #7
      WaitOnResourceSignals: true                  #8
      MinInstancesInService: 1                     #9

The Auto Scaling group references the launch template’s latest version and declares an `AutoScalingRollingUpdate` policy. Its example configuration allows one or two instances, providing room to launch a replacement before removing the old one. section 15.2

A rolling update trades the speed of changing an existing instance for a fresh start on each deployment. Unlike an in-place CodeDeploy deployment, it does not require modifying a long-running machine; unlike an immutable deployment built with Packer, this example installs and configures the application at boot through user data. section 15.1 section 15.2 section 15.5

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Walks through stack deployment, launch-template user data, Auto Scaling update policy, version change, and startup-log inspection.
Examples
Updates an Etherpad deployment from version 1.8.17 to 1.8.18 using a CloudFormation version parameter.
What it assumes
Assumes basic familiarity with EC2 high availability, Auto Scaling, Elastic Load Balancing, and CloudFormation.
What you can do after
Operate/configure a CloudFormation rolling update and inspect an EC2 startup log when deployment fails.
How it connects
Connects CloudFormation, Auto Scaling groups, EC2 launch templates, user data, Application Load Balancers, in-place deployments, and immutable deployments.

Also explained in

Compare how 8 books explain rolling update →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.