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

5,082 views

Published on

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.

Published in: Technology

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

  1. 1. Zero to Sixty: AWS Elastic Beanstalk Evan Brown, Amazon Web Services November 14, 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.
  2. 2. The Zero to Sixty Series • • • • Some Elastic Beanstalk experience assumed Practical tips and tricks Real stories, real advice, from real customers Q&A!
  3. 3. Featuring Ann Wallace and Amber Milavec, Nike Geraldo Thomaz, VTEX Gabriel Arrais, VTEX
  4. 4. Flow AWS NIKE VTEX Q&A (10m) (20m) (20m) (10m)
  5. 5. What you can do with AWS Elastic Beanstalk Practical Tips and Tricks
  6. 6. With AWS Elastic Beanstalk, you can… Build apps for 6 popular container types Java PHP Python Ruby .NET Node.js
  7. 7. With AWS Elastic Beanstalk, you can… Deploy your app to a load balanced, auto scaled Environment
  8. 8. http://your-app.elasticbeanstalk.com ELB Alert App Log AZ Mon
  9. 9. http://your-app.elasticbeanstalk.com ELB Alert App Log AZ Mon
  10. 10. http://your-app.elasticbeanstalk.com ELB Alert App Log AZ DB Mon AZ
  11. 11. With AWS Elastic Beanstalk, you can… Deploy your app to a Single Instance Environment
  12. 12. http://your-app-dev.elasticbeanstalk.com Alert App Log AZ DB Mon AZ
  13. 13. With AWS Elastic Beanstalk, you can… Environments exist within an Elastic Beanstalk Application
  14. 14. Application: YourWebApp Application Versions
  15. 15. With AWS Elastic Beanstalk, you can… Deploy your app using tools you know
  16. 16. Application Versions
  17. 17. Customizing Elastic Beanstalk
  18. 18. Customizing Elastic Beanstalk • The resources supporting your app – Adjust scaling policies – Add a key pair for SSH access – Create an S3 bucket • The software running on your instances – Install other software – Create or download files
  19. 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
  20. 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
  21. 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
  22. 22. Windows Download Agent Files to Instance files: "C:UsersPublicDownloadsEnableEc2SetComputerName.ps1”: source: http://<s3>/EnableEc2SetComputerName.ps1 "C:UsersPublicDownloadsNewRelicAgent.msi”: source: http://<s3>/NewRelicAgent_<platform>_<version>.msi "C:UsersPublicDownloadsNewRelicServerMonitor.msi”: source: http://<s3>/NewRelicServerMonitor_<platform>_<version>.msi
  23. 23. Windows Download Agent Files to Instance files: "C:UsersPublicDownloadsEnableEc2SetComputerName.ps1”: source: http://<s3>/EnableEc2SetComputerName.ps1 "C:UsersPublicDownloadsNewRelicAgent.msi”: source: http://<s3>/NewRelicAgent_<platform>_<version>.msi "C:UsersPublicDownloadsNewRelicServerMonitor.msi”: source: http://<s3>/NewRelicServerMonitor_<platform>_<version>.msi
  24. 24. Windows Download Agent Files to Instance commands: ec2setcomputername-enable: command: powershell.exe -ExecutionPolicy Bypass -File "C:Users PublicDownloadsEnableEc2SetComputerName.ps1" install_newrelic_agent: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicAgent.msi" /qb NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50 install_newrelic_servermonitor: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicServerMonitor.msi" /L*v install.log /qn NR_LICENSE_KEY=<new_relic_license_key>
  25. 25. Windows Download Agent Files to Instance commands: ec2setcomputername-enable: command: powershell.exe -ExecutionPolicy Bypass -File "C:Users PublicDownloadsEnableEc2SetComputerName.ps1" install_newrelic_agent: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicAgent.msi" /qb NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50 install_newrelic_servermonitor: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicServerMonitor.msi" /L*v install.log /qn NR_LICENSE_KEY=<new_relic_license_key>
  26. 26. Windows Download Agent Files to Instance commands: ec2setcomputername-enable: command: powershell.exe -ExecutionPolicy Bypass -File "C:Users PublicDownloadsEnableEc2SetComputerName.ps1" install_newrelic_agent: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicAgent.msi" /qb NR_LICENSE_KEY=<new_relic_license_key> INSTALLLEVEL=50 install_newrelic_servermonitor: command: msiexec.exe /i "C:UsersPublicDownloads NewRelicServerMonitor.msi" /L*v install.log /qn NR_LICENSE_KEY=<new_relic_license_key>
  27. 27. Customization Scenario • Application Configuration Store config in the environment
  28. 28. Windows Linux Store App Config in the Environment option_settings: - option_name: SOME_ENV_VAR_NAME value: ”env_var_value”
  29. 29. Linux Store App Config in the Environment option_settings: - option_name: ENV_VAR value: ”env_var_value” Python import os some_var=os.environ.get(‘ENV_VAR’) Java Windows String some_var = System.getProperty(‘ENV_VAR’) C# NameValueCollection appConfig = ConfigurationManager.AppSettings; string param1 = appConfig[”ENV_VAR"];
  30. 30. Linux Store App Config in the Environment option_settings: - option_name: ENV_VAR value: ”env_var_value” Python import os some_var=os.environ.get(‘ENV_VAR’) Java Windows String some_var = System.getProperty(‘ENV_VAR’) C# NameValueCollection appConfig = ConfigurationManager.AppSettings; string param1 = appConfig[”ENV_VAR"];
  31. 31. Linux Store App Config in the Environment option_settings: - option_name: ENV_VAR value: ”env_var_value” Python import os some_var=os.environ.get(‘ENV_VAR’) Java Windows String some_var = System.getProperty(‘ENV_VAR’) C# NameValueCollection appConfig = ConfigurationManager.AppSettings; string param1 = appConfig[”ENV_VAR"];
  32. 32. Windows Linux 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"}
  33. 33. AWS Elastic Beanstalk at Nike Ann Wallace :: @randombug :: Nike, Inc. Amber Milavec :: @noneonnone :: Nike, Inc. © 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.
  34. 34. Where does Nike use Elastic Beanstalk? • Brand and marketing campaigns • Stand-alone apps that only integrate with Nike web services
  35. 35. Why does Nike use Elastic Beanstalk? • • • • Ease of use Agility Familiarity Distributed deployment model
  36. 36. How does Nike use Elastic Beanstalk? " *'$) 78/ ) 06/ & 9 ) " #+ : '; #' $) 78/ ) & !" #$%& ' ( ) #*$+ , ' #" - . . "& / #%0* - 12 ' 3 #+ 4 #5 ) ) < #/ '$) 78/ ) " & 6#< ) '$) 78/ ) &
  37. 37. Standard Elastic Beanstalk Application setup
  38. 38. Deployment UI
  39. 39. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' Elastic Beanstalk Deployment Process
  40. 40. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' 89' 30) 3*&-!$ , ..& $ 4: ' $ $ $ ' / "-3$ / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' Elastic Beanstalk Deployment Process
  41. 41. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' ; 9' 30) 3*&-!$ , ..& $ 4< ' $ $ $ ' / "-3$ 89& !' & 0$ 353$ ' , ..& $ $ #"$ 0-: / -!$ / / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' Elastic Beanstalk Deployment Process ) & "3., &/ + 2$ $
  42. 42. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' ; 9' 30) 3*&-!$ , ..& $ 4< ' $ $ $ ' / "-3$ 89& !' & 0$ 353$ ' , ..& $ $ #"$ 0-: / -!$ / / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( =9+& $ 3#!53.) $ #: *$ .&-!$ & / $ 0( : $ 0% 35& ! , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' Elastic Beanstalk Deployment Process ) & "3., &/ + 2$ $
  43. 43. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' ; 9' 30) 3*&-!$ , ..& $ 4< ' $ $ $ ' / "-3$ ) & "3., &/ + 2$ $ 89& !' & 0$ 353$ ' , ..& $ $ #"$ 0-: / -!$ / / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( >9? 3%: .& -!$ ' -& $ $ $ $ $ 0( / 5( !=$ =9+& $ 3#!53.) $ #: *$ .&-!$ & / $ 0( : $ 0% 35& # , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' Elastic Beanstalk Deployment Process !"
  44. 44. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' ; 9' 30) 3*&-!$ , ..& $ 4< ' $ $ $ ' / "-3$ ) & "3., &/ + 2$ $ 89& !' & 0$ 353$ ' , ..& $ $ #"$ 0-: / -!$ / / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( >9? 3%: .& -!$ ' -& $ $ $ $ $ 0( / 5( !=$ =9+& $ 3#!53.) $ #: *$ .&-!$ & / $ 0( : $ 0% 35& # , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' @$ 3#!53.) $ #"-% #A & -!$ & / 9+& & ( #5$ 0% 35& Elastic Beanstalk Deployment Process !"
  45. 45. , !& $ 0) !$ 0( / & %04& -#$ !"#$ & ( %' +, -./ $ ) -0) & $ 1 -!$ /( / & .( 23+.&' 30) 3*& ' $ -!$ , !4& $ $ $ ' / 5( 54& ' ) *$ & ( $ %' ' ) *$ & ( %' ) & "3., &/ + 2$ $ ; 9' 30) 3*&-!$ , ..& $ 4< ' $ $ $ ' / "-3$ 89& !' & 0$ 353$ ' , ..& $ $ #"$ 0-: / -!$ / / & .( 2$ ' , / & .( 2$ / & -!$ ' 0( $ -#-735& $ / +& 3#!53.) ' % 62$ !5 ( 4( >9? 3%: .& -!$ ' -& $ $ $ $ $ 0( / 5( !=$ =9+& $ 3#!53.) $ #: *$ .&-!$ & / $ 0( : $ 0% 35& # , !& $ .& & 3#/ $ ) *$ $ & .( 2 %!& 05!$ #"$ ' 5( / ' !" B9+& $ 3#!53.) $ , ..!$ $ 3%: .& ' 54& ? $ C ( A $ C %/ & .( 2A & % !=$( $ ' #5 @$ 3#!53.) $ #"-% #A & -!$ & / 9+& & ( #5$ 0% 35& Elastic Beanstalk Deployment Process
  46. 46. Under the covers • • • • Configuration templates .ebextensions Zero downtime deployments Wild card certs
  47. 47. Zero downtime deployments create a new environment deploy new app version and configuration is status ready && health green? > 10 mins FAIL no cname swap new env has to be manually deleted Yes swap cname of old env with new env terminate old env
  48. 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" },
  49. 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"
  50. 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
  51. 51. Geraldo Thomaz, co-CEO
  52. 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
  53. 53. Why and How does VTEX use AWS?
  54. 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
  55. 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 Continuous integration, automation, fast rollback, monitoring 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 AWS Elastic Beanstalk TeamCity, Splunk, Varnish/Nginx (VTEX Janus)
  56. 56. DEMO
  57. 57. Our Beanstalk Console
  58. 58. TeamCity – The Build Server
  59. 59. Awsdeploy command line tool
  60. 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
  61. 61. We use Splunk and Elastic Beanstalk interface for Monitoring
  62. 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?
  63. 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
  64. 64. And now it’s time for…
  65. 65. And now it’s time for… • Q & A!
  66. 66. Coming up right after this… DMG301 - AWS Elastic Beanstalk Under the Hood © 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.
  67. 67. Please give us your feedback on this presentation DMG204 As a thank you, we will select prize winners daily for completed surveys!

×