Page 1
© 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
Page 2
The Zero to Sixty Series
• Some Elastic Beanstalk experience assumed
• Practical tips and tricks
• Real stories, real advice, from real customers
• Q&A!
Page 3
Featuring
Ann Wallace and Amber
Milavec, Nike
Geraldo Thomaz, VTEX
Gabriel Arrais, VTEX
Page 4
Flow
AWS (10m)
NIKE (20m)
VTEX (20m)
Q&A (10m)
Page 5
Practical Tips and Tricks
What you can do with AWS Elastic Beanstalk
Page 6
Build apps for 6 popular container types
With AWS Elastic Beanstalk, you can…
Java PHP Python Ruby .NET Node.js
Page 7
Deploy your app to a load balanced, auto
scaled Environment
With AWS Elastic Beanstalk, you can…
Page 8
Alert
Log
Mon A
pp
E
LB
AZ
http://your-app.elasticbeanstalk.com
Page 9
Alert
Log
Mon A
pp
AZ
EL
B
http://your-app.elasticbeanstalk.com
Page 10
Alert
DB
Log
Mon A
pp
AZ
AZ
EL
B
http://your-app.elasticbeanstalk.com
Page 11
Deploy your app to a Single Instance
Environment
With AWS Elastic Beanstalk, you can…
Page 12
Alert
DB
Log
Mon A
pp
AZ
AZ
http://your-app-dev.elasticbeanstalk.com
Page 13
Environments exist within an Elastic
Beanstalk Application
With AWS Elastic Beanstalk, you can…
Page 14
Application: YourWebApp
Application Versions
Page 15
Deploy your app using tools you know
With AWS Elastic Beanstalk, you can…
Page 16
Application Versions
Page 17
Customizing Elastic Beanstalk
Page 18
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
Page 19
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
Page 20
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
Page 21
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
Page 22
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
Page 23
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
Page 24
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
Page 25
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
Page 26
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
Page 27
Customization Scenario
• Application Configuration
Store config in the environment
Page 28
Store App Config in the Environment option_settings:
- option_name: SOME_ENV_VAR_NAME
value: ”env_var_value”
Win
do
ws
L
inu
x
Page 29
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#
Page 30
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#
Page 31
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#
Page 32
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
Page 33
© 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.
Page 34
Where does Nike use Elastic Beanstalk?
• Brand and marketing campaigns
• Stand-alone apps that only integrate with Nike
web services
Page 35
Why does Nike use Elastic Beanstalk?
• Ease of use
• Agility
• Familiarity
• Distributed deployment model
Page 36
How does Nike use Elastic Beanstalk?
! "#$%&'( ) #*$+#", '- . . "/&#%0*
- 12'3 #+) 4 #5
"06/*'$) 78/&)
9: ) "'; #+#'$) 78/&)
) < #/"'$) 78/&)
6#< ) '$) 78/&)
Page 37
Standard Elastic Beanstalk Application setup
Page 39
Elastic Beanstalk Deployment Process
!"#$%&' ( ' ) *$%&' (
+, -./$-!$) -0)&/$( 1/&' .( 23+.&$' 30) 3*&-!$' , !4&/$5( $54&$
' ) *$%&' ( $
, !&%$04&0) !$-#$0( /&
Page 40
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( /&
Page 41
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( /&
Page 42
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( /&
Page 43
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( /&
Page 44
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 $-!$0%&35&/
, !&%$04&0) !$-#$0( /&
Page 45
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 $-!$0%&35&/
B9$+&3#!53.) $' , ..!$54&$? 3%$: .&C%( A $!=$C( %$/&' .( 2A 
, !&%$04&0) !$-#$0( /&
Page 46
Under the covers
• Configuration templates
• .ebextensions
• Zero downtime deployments
• Wild card certs
Page 47
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
Page 48
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"
},
Page 49
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"
Page 50
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
Page 51
Geraldo Thomaz, co-CEO
Page 52
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
Page 53
Why and How does VTEX use AWS?
Page 54
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
Page 55
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)
Page 57
Our Beanstalk Console
Page 58
TeamCity – The Build Server
Page 59
Awsdeploy command line tool
Page 60
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
Page 61
We use Splunk and Elastic Beanstalk interface
for Monitoring
Page 62
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?
Page 63
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
Page 64
And now it’s time for…
Page 65
And now it’s time for…
• Q & A!
Page 66
© 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
Page 67
Please give us your feedback on this
presentation
As a thank you, we will select prize
winners daily for completed surveys!
DMG204