Zero to Sixty: AWS Elastic Beanstalk (DMG204) | AWS re:Invent 2013

Post on 15-Jan-2015

2.115 views 6 download

Tags:

description

AWS Elastic Beanstalk provides an easy way for you to quickly deploy and manage applications in the AWS cloud. In this Zero to Sixty session, accelerate your use of Elastic Beanstalk by learning how Nike and VTEX use several of its most powerful features. Through interactive demos and code samples for both Windows and Linux, this session teaches you how to achieve deployments with zero downtime, how to easily enable or disable application functionality via feature flags, and how to customize your Elastic Beanstalk environments with extensions. Demos and code samples are available to all session attendees. Are you new to Elastic Beanstalk? Get up to speed for this session by first completing the 60-minute Fundamentals of Elastic Beanstalk lab in the Self Paced Lab Lounge.

Transcript of Zero to Sixty: AWS Elastic Beanstalk (DMG204) | 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.

Zero to Sixty: AWS Elastic Beanstalk

Evan Brown, Amazon Web Services

November 14, 2013

The Zero to Sixty Series

• Some Elastic Beanstalk experience assumed

• Practical tips and tricks

• Real stories, real advice, from real customers

• Q&A!

Featuring

Ann Wallace and Amber

Milavec, Nike

Geraldo Thomaz, VTEX

Gabriel Arrais, VTEX

Flow

AWS (10m)

NIKE (20m)

VTEX (20m)

Q&A (10m)

Practical Tips and Tricks

What you can do with AWS Elastic Beanstalk

Build apps for 6 popular container types

With AWS Elastic Beanstalk, you can…

Java PHP Python Ruby .NET Node.js

Deploy your app to a load balanced, auto

scaled Environment

With AWS Elastic Beanstalk, you can…

Alert

Log

Mon A

pp

E

LB

AZ

http://your-app.elasticbeanstalk.com

Alert

Log

Mon A

pp

AZ

EL

B

http://your-app.elasticbeanstalk.com

Alert

DB

Log

Mon A

pp

AZ

AZ

EL

B

http://your-app.elasticbeanstalk.com

Deploy your app to a Single Instance

Environment

With AWS Elastic Beanstalk, you can…

Alert

DB

Log

Mon A

pp

AZ

AZ

http://your-app-dev.elasticbeanstalk.com

Environments exist within an Elastic

Beanstalk Application

With AWS Elastic Beanstalk, you can…

Application: YourWebApp

Application Versions

Deploy your app using tools you know

With AWS Elastic Beanstalk, you can…

Application Versions

Customizing Elastic Beanstalk

Customizing Elastic Beanstalk

• The software running

on your instances

– Install other software

– Create or download

files

• The resources

supporting your app

– Adjust scaling policies

– Add a key pair for SSH

access

– Create an S3 bucket

Customizing Elastic Beanstalk

• In 3 steps: 1. Add a .ebextensions folder to your app/project

2. Define customizations in YAML config files

3. Package and deploy app to Elastic Beanstalk

Customizing Elastic Beanstalk

• In 3 steps: 1. Add a .ebextensions folder to your app/project

2. Define customizations in YAML-formatted config files

3. Package and deploy app to Elastic Beanstalk

Customization Scenario

• .NET Application on Windows Server

• Automatically Install New Relic Server Monitor

on each instance

Courtesy of Travis Cannon

Complete code available at https://gist.github.com/TravisCannon/6023875

Download Agent Files to Instance files:

"C:\\Users\\Public\\Downloads\\EnableEc2SetComputerName.ps1”:

source: http://<s3>/EnableEc2SetComputerName.ps1

"C:\\Users\\Public\\Downloads\\NewRelicAgent.msi”:

source: http://<s3>/NewRelicAgent_<platform>_<version>.msi

"C:\\Users\\Public\\Downloads\\NewRelicServerMonitor.msi”:

source: http://<s3>/NewRelicServerMonitor_<platform>_<version>.msi

Win

do

ws

Download Agent Files to Instance files:

"C:\\Users\\Public\\Downloads\\EnableEc2SetComputerName.ps1”:

source: http://<s3>/EnableEc2SetComputerName.ps1

"C:\\Users\\Public\\Downloads\\NewRelicAgent.msi”:

source: http://<s3>/NewRelicAgent_<platform>_<version>.msi

"C:\\Users\\Public\\Downloads\\NewRelicServerMonitor.msi”:

source: http://<s3>/NewRelicServerMonitor_<platform>_<version>.msi

Win

do

ws

Download Agent Files to Instance commands:

ec2setcomputername-enable:

command: powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\

\Public\\Downloads\\EnableEc2SetComputerName.ps1"

install_newrelic_agent:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicAgent.msi" /qb

NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50

install_newrelic_servermonitor:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicServerMonitor.msi" /L*v install.log /qn

NR_LICENSE_KEY=<new_relic_license_key>

Win

do

ws

Download Agent Files to Instance commands:

ec2setcomputername-enable:

command: powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\

\Public\\Downloads\\EnableEc2SetComputerName.ps1"

install_newrelic_agent:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicAgent.msi" /qb

NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50

install_newrelic_servermonitor:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicServerMonitor.msi" /L*v install.log /qn

NR_LICENSE_KEY=<new_relic_license_key>

Win

do

ws

Download Agent Files to Instance commands:

ec2setcomputername-enable:

command: powershell.exe -ExecutionPolicy Bypass -File "C:\\Users\

\Public\\Downloads\\EnableEc2SetComputerName.ps1"

install_newrelic_agent:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicAgent.msi" /qb

NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50

install_newrelic_servermonitor:

command: msiexec.exe /i "C:\\Users\\Public\\Downloads\

\NewRelicServerMonitor.msi" /L*v install.log /qn

NR_LICENSE_KEY=<new_relic_license_key>

Win

do

ws

Customization Scenario

• Application Configuration

Store config in the environment

Store App Config in the Environment option_settings:

- option_name: SOME_ENV_VAR_NAME

value: ”env_var_value”

Win

do

ws

L

inu

x

Store App Config in the Environment option_settings:

- option_name: ENV_VAR

value: ”env_var_value”

Win

do

ws

L

inu

x

import os

some_var=os.environ.get(‘ENV_VAR’)

String some_var = System.getProperty(‘ENV_VAR’)

NameValueCollection appConfig = ConfigurationManager.AppSettings;

string param1 = appConfig[”ENV_VAR"];

Python

Java

C#

Store App Config in the Environment option_settings:

- option_name: ENV_VAR

value: ”env_var_value”

Win

do

ws

L

inu

x

import os

some_var=os.environ.get(‘ENV_VAR’)

String some_var = System.getProperty(‘ENV_VAR’)

NameValueCollection appConfig = ConfigurationManager.AppSettings;

string param1 = appConfig[”ENV_VAR"];

Python

Java

C#

Store App Config in the Environment option_settings:

- option_name: ENV_VAR

value: ”env_var_value”

Win

do

ws

L

inu

x

import os

some_var=os.environ.get(‘ENV_VAR’)

String some_var = System.getProperty(‘ENV_VAR’)

NameValueCollection appConfig = ConfigurationManager.AppSettings;

string param1 = appConfig[”ENV_VAR"];

Python

Java

C#

Store App Config in the Environment option_settings:

- option_name: CDN_DNS

value: ”http://dmorf1fvvsmuy.cloudfront.net”

option_settings:

- option_name: DB_CONN_STRING

value: ”jdbc:mysql://3yta.us-west-2.

rds.amazonaws.com:3306/amediamanager”

option_settings:

- option_name: ENABLE_MEMCACHED

value: ”false”

option_settings:

- option_name: AWS_REGION

value: { "Ref" : "AWS::Region"}

Win

do

ws

L

inu

x

© 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.

AWS Elastic Beanstalk at Nike

Ann Wallace :: @randombug :: Nike, Inc.

Amber Milavec :: @noneonnone :: Nike, Inc.

Where does Nike use Elastic Beanstalk?

• Brand and marketing campaigns

• Stand-alone apps that only integrate with Nike

web services

Why does Nike use Elastic Beanstalk?

• Ease of use

• Agility

• Familiarity

• Distributed deployment model

How does Nike use Elastic Beanstalk?

! "#$%&'( ) #*$+#", '- . . "/&#%0*

- 12'3 #+) 4 #5

"06/*'$) 78/&)

9: ) "'; #+#'$) 78/&)

) < #/"'$) 78/&)

6#< ) '$) 78/&)

Standard Elastic Beanstalk Application setup

Deployment UI

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

89$' 30) 3*&$-!$' , ..&/$"-3$4: ' $

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

)&2$"3., &$/+

89$&#"$!' &0-: 0$/353$-!$' , ..&/$

; 9$' 30) 3*&$-!$' , ..&/$"-3$4< ' $

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

)&2$"3., &$/+

89$&#"$!' &0-: 0$/353$-!$' , ..&/$

; 9$' 30) 3*&$-!$' , ..&/$"-3$4< ' $

=9$+&3#!53.) $0( #: *$: .&$-!$0%&35&/$!

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

! "

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

)&2$"3., &$/+

89$&#"$!' &0-: 0$/353$-!$' , ..&/$

; 9$' 30) 3*&$-!$' , ..&/$"-3$4< ' $

=9$+&3#!53.) $0( #: *$: .&$-!$0%&35&/$#

>9$? 3%$: .&$-!$0( ' -&/$5( $!=$

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

! "

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

)&2$"3., &$/+

89$&#"$!' &0-: 0$/353$-!$' , ..&/$

; 9$' 30) 3*&$-!$' , ..&/$"-3$4< ' $

=9$+&3#!53.) $0( #: *$: .&$-!$0%&35&/$#

>9$? 3%$: .&$-!$0( ' -&/$5( $!=$

@9$+&3#!53.) $&#"-%( #A &#5$-!$0%&35&/

, !&%$04&0) !$-#$0( /&

Elastic Beanstalk Deployment Process

!"#$%&' ( ' ) *$%&' (

+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$

' ) *$%&' ( $

/&' .( 2$, - +&3#!53.)' %( 62$4( !5

! "

, !&%$!&.&05!$&#"$3#/$' ) *$5( $/&' .( 2

/&' .( 2$0( /&$-!$-#-735&/$

)&2$"3., &$/+

89$&#"$!' &0-: 0$/353$-!$' , ..&/$

; 9$' 30) 3*&$-!$' , ..&/$"-3$4< ' $

=9$+&3#!53.) $0( #: *$: .&$-!$0%&35&/$#

>9$? 3%$: .&$-!$0( ' -&/$5( $!=$

@9$+&3#!53.) $&#"-%( #A &#5$-!$0%&35&/

B9$+&3#!53.) $' , ..!$54&$? 3%$: .&C%( A $!=$C( %$/&' .( 2A &#5

, !&%$04&0) !$-#$0( /&

Under the covers

• Configuration templates

• .ebextensions

• Zero downtime deployments

• Wild card certs

Zero downtime deployments

create a new

environment

deploy new app

version and

configuration

is status

ready &&

health

green?

swap cname of

old env with

new env

terminate old

env

FAIL

no cname swap

new env has to

be manually

deleted

> 10 mins

Yes

template.json example {

"Value" : "%%healthcheck.page%%",

"Namespace" : "aws:elasticbeanstalk:application",

"OptionName" : "Application Healthcheck URL"

},

{

"Value" : "%%autoscale.measure%%",

"Namespace" : "aws:autoscaling:trigger",

"OptionName" : "MeasureName"

},

{

"Value" : "%%autoscale.stat%%",

"Namespace" : "aws:autoscaling:trigger",

"OptionName" : "Statistic"

},

New Relic .ebextensions example container_commands:

00-new-relic:

command: wget https://X.s3.amazonaws.com/newrelic_agent.zip

cwd: /tmp

01-unzip:

command: unzip -j newrelic_agent.zip -d /usr/share/java/tomcat6

cwd: /tmp

option_settings:

- namespace: aws:elasticbeanstalk:container:tomcat:jvmoptions

option_name: "JVM Options"

value: "-javaagent:/usr/share/java/tomcat6/newrelic.jar"

It’s not all rainbows and unicorns

• Unable to deploy multiple wars to one environment

• Unable to update a cert without redeploying

• Log access

• Developers still say “it works on my box”

• Boot time / deployment cycles take awhile

Geraldo Thomaz, co-CEO

VTEX who? • Started in 2000, after MANY pivots, we

focused in SAAS E-Commerce Platform,

and we are growing, since 2009, an

average of 70%/year

• Today we are the preferred platform for

more than 400 customers, in 8 LATAM countries

• Our customers generates more than U$

1bi in gross merchandise value

• More than 200 million page-views/month

delivered through AWS infrastructure

Why and How does VTEX use AWS?

Why and How does VTEX use Elastic Beanstalk?

Our goal:

Satisfy more than 1000 customers

Maximum Availability - with minimal downtime

Minimum Cost - building a multi-tenant application

Why and How does VTEX use Elastic Beanstalk?

Increase the number of thinking minds, not

developers only

(in one year, our tech team grew from 15 to 170)

Make every one of the 170 count, giving ownership to

most of them

SOA, split our product into more than 30

independent services

Create a code-delivery infrastructure that minimizes downtime, deployment errors, Q&A and gives incentives for

small batches

Continuous integration, automation, fast rollback, monitoring

AWS Elastic Beanstalk

TeamCity, Splunk, Varnish/Nginx (VTEX Janus)

DEMO

Our Beanstalk Console

TeamCity – The Build Server

Awsdeploy command line tool

Ebextension to install Splunk sources:

c:\temp: https://loggerdeploy.s3.amazonaws.com/LoggerSplunkForwarderSetup.zip

commands:

install-vtexLogger:

command: LoggerSplunkForwarderSetup.exe

cwd: c:\temp

waitForCompletion: 0

services:

windows:

SplunkForwarder:

enabled: true

ensureRunning: true

We use Splunk and Elastic Beanstalk interface

for Monitoring

Roadmap

• Make Janus distribute load between two

versions and ask Splunk if the new version is

better than the previous one – Lower Error/Warn Rate?

– Lower Latency?

– Lower Resource Consumption?

Remarks

• Ownership to the service teams

• Bad version has limited impact

• Q&A protects the job of our developers – Rollback protects the credibility of VTEX

And now it’s time for…

And now it’s time for…

• Q & A!

© 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.

Coming up right after this…

DMG301 - AWS Elastic Beanstalk Under the Hood

Please give us your feedback on this

presentation

As a thank you, we will select prize

winners daily for completed surveys!

DMG204