aws elastic beanstalk under the hood (dmg301) | aws re:invent 2013

60
© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc. DMG301 AWS Elastic Beanstalk Under the Hood Chris Whitaker, Amazon Web Services November 14, 2013

Upload: amazon-web-services

Post on 15-Jan-2015

4.820 views

Category:

Technology


1 download

DESCRIPTION

AWS Elastic Beanstalk provides a number of simple, flexible interfaces for developing and deploying your applications. In this session, learn how ThoughtWorks leverage the Elastic Beanstalk API to continuously deliver their applications with smoke tests and blue-green deployments. Also learn how to deploy your apps with Git and eb, a powerful CLI that allows developers to create, configure, and manage Elastic Beanstalk applications and environments from the command line.

TRANSCRIPT

Page 1: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

© 2013 Amazon.com, Inc. and its affiliates. All rights reserved. May not be copied, modified, or distributed in whole or in part without the express consent of Amazon.com, Inc.

DMG301 – AWS Elastic Beanstalk Under the Hood

Chris Whitaker, Amazon Web Services

November 14, 2013

Page 2: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Featuring

Sudhindra R Rao and Pengchao Wang,

ThoughtWorks

Page 3: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Have you ever wanted to…

• Control the lifetime of your AWS resources

separately from your application code?

• Extend or add more AWS resources to your

Elastic Beanstalk environment?

• Control traffic to your application as you deploy?

You have come to the right place!

Page 4: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Under the Hood Series

• Elastic Beanstalk experience assumed

• Practical tips and tricks

• Real stories, real advice, from real customers

• Q&A!

Page 5: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Flow

AWS (25m)

ThoughtWorks (25m)

Q&A (10m)

Page 6: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling the Lifetime

• Out-of-the-box Elastic Beanstalk supports – Amazon Relational Database Service (RDS)

• Tied to the lifetime of your environment – Terminating or rebuilding your environment removes or replaces

your database

• Use AWS CloudFormation to manage resource

lifetimes independently

Page 7: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Resource Lifetime

Alert

Log

Mon A

pp

AZ

EL

B

Terminate

environment

http://www.your-app.com

Page 8: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Resource Lifetime

Alert

Log

Mon A

pp

AZ

EL

B

Terminate

environment

http://www.your-app.com

Page 9: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

A CloudFormation Template

• Demo

Page 10: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Extending Your Configuration

• Elastic Beanstalk gives you the following: – Load balanced, auto scaling; single instance

– Amazon RDS database

• What if your application needs other resources – Amazon ElastiCache cache cluster, Amazon DynamoDB table,

Amazon Elastic Block Store (EBS) volumes, Amazon CloudWatch alarms…

• Two options – Elastic Beanstalk extensions (resources with lifetime tied to the code or

instance)

– AWS CloudFormation templates (resources with independent lifetime)

Page 11: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Adding Resources Using EBExtensions

Alert

Log

Mon Ap

p

AZ

EL

B

http://www.your-app.com

EBS EBS

Page 12: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Adding Resources using CloudFormation

Alert

Log

Mon Ap

p

AZ

EL

B

http://www.your-app.com

option_settings:

"aws:autoscaling:launchconfiguation":

InstanceType: "m1.large"

BlockDeviceMappings: "/dev/sdj:100"

Resources:

AlarmTopic:

Type: AWS::SNS::Topic

Properties: …

CpuAlarm:

Type: AWS::CloudWatch::Alarm

Properties…

EBS EBS

create_resources.config

Page 13: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Extending Your Configuration

• Attach an EBS-optimized volume

• Supported directly by Elastic Beanstalk

option_settings:

"aws:autoscaling:launchconfiguation":

InstanceType: "m1.large"

BlockDeviceMappings: "/dev/sdj:100"

Page 14: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Extending Your Configuration

• Adding additional resources (Alarm and Topic)

AlarmTopic:

Type: AWS::SNS::Topic

Properties:

Subscription:

- Endpoint:

Fn::GetOptionSetting:

OptionName: AlarmEmail

DefaultValue: "[email protected]"

Protocol: email

CpuAlarm:

Type: AWS::CloudWatch::Alarm

Properties:

AlarmDescription: "Alarm if CPU grows beyond 90%"

Namespace: "AWS/EC2"

MetricName: CPUUtilization

Dimensions:

- Name: AutoScalingGroupName

Value : { "Ref" : "AWSEBAutoScalingGroup" }

Statistic: Average

Period: 300

EvaluationPeriods: 1

Threshold: 90

ComparisonOperator: GreaterThanThreshold

AlarmActions:

- Ref: AlarmTopic

Page 15: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Built-in Resources Resource Name Description

AWSEBAutoScalingGroup The name of the Auto Scaling group that Elastic Beanstalk uses

when it launches Amazon EC2 instances.

AWSEBAutoScalingLaunchConfiguration The name for the launch configuration settings that Elastic

Beanstalk uses when it launches EC2 instances.

AWSEBEnvironmentName The name of the Elastic Beanstalk environment.

AWSEBLoadBalancer The name of the elastic load balancer used in the Elastic Beanstalk

environment.

AWSEBRDSDatabase The name of the Amazon RDS database.

AWSEBSecurityGroup The name for the EC2 security group that Elastic Beanstalk uses

when it launches EC2 instances.

Page 16: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Advanced Deployment Techniques

• Deploying to QA and Production using branches – Use multiple Git branches deployed to multiple environments

• Zero downtime deployments using CNAME flip – Deploy a new version even under heavy load

• Controlling traffic using Amazon Route 53 – Define how much traffic is directed to your new version

Page 17: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Using Branches

Users

git commit Branch1

Branch2

Git repository

V1

V2

V1

V2

Page 18: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Deploying Using Multiple Branches

git init

eb init

git add .

… edit your source

git commit

git aws.push

git branch v1

git checkout v1

eb branch

git aws.push

git checkout master

… edit your source

git aws.push

Test cycle deployed to test

Create a V1 branch and deploy

to production

Continue to develop and test

Page 19: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Zero Downtime Deployments

• Deploy new version with zero downtime and

ability to roll back (i.e., CNAME swap)

Page 20: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1

Page 21: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1

Page 22: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1 V2 V2

Page 23: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1 V2 V2

Page 24: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1 V2 V2

Page 25: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1 V2 V2

Page 26: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://www.your-app.com

V1 V1 V2 V2

Page 27: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling Traffic

• What if you want more control of the traffic when

you deploy a new version?

• Use Amazon Route 53 weighted resource

record sets – Associate multiple Elastic Beanstalk environments with the

same DNS name

– Control traffic flow using weights

Page 28: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling Traffic

http://your-app.com

Weight 100

Weight 0

V2 V2

V1 V1

Page 29: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling Traffic

http://your-app.com

Weight 100

Weight 10

V2 V2

V1 V1

Page 30: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling Traffic

http://your-app.com

Weight 0

Weight 100

V2 V2

V1 V1

Page 31: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Controlling Traffic

• Demo

Page 32: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Geographic Load Balancing

• Extend the Amazon Route53 idea to use latency

record sets – Associate multiple Elastic Beanstalk environments in different

regions with the same DNS name

– Latency-based routing selects the “nearest” Elastic Beanstalk

environment

Page 33: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Call to Action

• Customize your infrastructure with EBExtensions

• Use AWS CloudFormation in conjunction with Elastic Beanstalk to control resources lifetime

• Deploy using multiple branches for development and production

• Use CNAME flip or Amazon Route 53 configuration to manage your deployments

Page 34: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Other Resources

• DMG204 - Zero to Sixty: AWS Elastic Beanstalk

• DMG201 - Zero to Sixty: AWS CloudFormation

• DMG303 - AWS CloudFormation Under the Hood

Come find me in the developer resources booth

Page 35: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Sudhindra R Rao and Pengchao Wang

Page 36: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Blue-Green Deployments with AWS

Elastic Beanstalk

Page 37: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Elastic Beanstalk

I am so

beautiful

!

Page 38: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Elastic Beanstalk – Missing Parts?

Automated Blue-Green

Deployments

Page 39: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

http://thoughtworksstudios.github.io/eb_deployer

AWS Elastic Beanstalk blue-green deployment automation

Page 40: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Blue Green Deployments on Elastic Beanstalk

version n

version n+1 testing

terminate

Page 41: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer Automates Blue-Green Deployments

Page 42: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Deployment with EbDeployer

version n

version n+1 smoke tests

scale down

Page 43: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Package and Deploy

Page 44: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

A Sample Smoke Test

Page 45: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Demo

Page 46: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer Makes Shared Resource

Blue-Green Deployments Easier

Page 47: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Elastic Beanstalk Resource Management

version n

version n+1

Page 48: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Shared Resources

version n

version n+1

Page 49: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer

Adding RDS to the Deployment

Page 50: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Add a CloudFormation Template for RDS

Page 51: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Add Resource Declaration

Page 52: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Demo

Page 53: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer Provides Different

Deployment Flavors

Page 54: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

• phoenix_mode: true

Phoenix Server

Page 55: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Deployment Strategy

• blue-green vs. inplace-update

Page 56: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer in Our Pipeline

Page 57: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Continuous Delivery

Page 58: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

EbDeployer

Page 59: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Have a Pull Request?

http://thoughtworksstudios.github.io/eb_deployer

[email protected] @alexhal9000

[email protected] @sudhindraRao

Page 60: AWS Elastic Beanstalk under the Hood (DMG301) | AWS re:Invent 2013

Please give us your feedback on this

presentation

As a thank you, we will select prize

winners daily for completed surveys!

DMG301