Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

(DVO201) Scaling Your Web Applications with AWS Elastic Beanstalk

5,889 views

Published on

AWS Elastic Beanstalk provides an easy way for you to quickly deploy, manage, and scale applications in the AWS cloud. Through interactive demos and code samples, this session will teach you how to deploy your code to Elastic Beanstalk, provision and use additional AWS resources (for example, Amazon SNS, Amazon SQS, and Amazon DynamoDB), use your application’s health metrics to tune performance, scale your application to handle millions of requests, and perform zero-downtime deployments with traffic routing. Demos and code samples will be available to all session attendees.

Published in: Technology

(DVO201) Scaling Your Web Applications with AWS Elastic Beanstalk

  1. 1. © 2015, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Abhishek Singh | Sr. Product Manager | AWS Elastic Beanstalk Colin Angel | Technical Director | Isobar (Royal Caribbean Cruises Ltd.) October 2015 DVO201 Deploying and Scaling Web Applications with AWS Elastic Beanstalk
  2. 2. Agenda • AWS Elastic Beanstalk (Elastic Beanstalk) vs. DIY • Developer workflow (sample application) • Demo • Best practices • Demo • Customer story
  3. 3. After this session, you should be able to: • Understand the benefits of using Elastic Beanstalk vs. DIY • Deploy applications to Elastic Beanstalk using the EB command line interface (EB CLI) • Modify application configuration (e.g., environment variables, proxy, etc.) • Extend applications to use additional AWS resources (e.g., Amazon RDS, Amazon SNS, etc.) • Debug, load test, and scale applications to handle millions of web requests • Use deployment options available for zero-downtime deployments: • Rolling deployments (in-place deployments) • Swap URL (blue/green deployments) • Set up alarms and notifications to monitor your running applications • Use tags for cost management
  4. 4. Elastic Beanstalk vs. DIY Your code HTTP server Application server Language interpreter Operating system Host Elastic Beanstalk configures each EC2 instance in your environment with the components necessary to run applications for the selected platform. No more worrying about logging into instances to install and configure your application stack. Focus on building your application Provided by you Provided and managed by Elastic Beanstalk On-instance configuration
  5. 5. Elastic Beanstalk vs. DIY • Preconfigured infrastructure: • Single-instance (dev, low cost) • Load-balanced, Auto Scaling (production) • Web and worker tiers • Elastic Beanstalk provisions necessary infrastructure resources, such as the load balancer, Auto Scaling group, security groups, database (optional), etc. • Provides a unique domain name for your application (e.g., yourapp.elasticbeanstalk.com) Infrastructure stack
  6. 6. Information required to deploy an application 01 02 03 04 Region Stack (container) type Single-instance Load balanced with autoscaling Or Database (RDS) Optional Your code Supported platforms
  7. 7. How to deploy applications 1. With the AWS Management Console 2. With the AWS Toolkit for Eclipse and Visual Studio IDE 3. With the EB command line interface (EB CLI) $ eb deploy
  8. 8. Deploy a sample application Initial application deployment workflow: $ git clone https://github.com/awslabs/eb- node-express-sample.git Download the sample application:02 $ eb init Create your Elastic Beanstalk app:03 Follow the prompts to configure the environment 04 05 Create the resources and launch the application: $ eb create $ pip install --upgrade awsebcli Install the EB CLI:01
  9. 9. Update the sample application Workflow for updating the application: Update your code01 $ git add . $ git commit –m “v2.0” $ eb deploy Add and commit code to repository:02 Open the application after deployment completes: 03 $ eb open
  10. 10. Sample application details Application dependency management
  11. 11. package.json { "name": "Elastic-Beanstalk-Sample-App", "version": "0.0.1", "private": true, "dependencies": { "ejs": "latest", "aws-sdk": "latest", "express": "latest", "body-parser": "latest" }, "scripts": { "start": "node app.js" } }
  12. 12. package.json { "name": "Elastic-Beanstalk-Sample-App", "version": "0.0.1", "private": true, "dependencies": { "ejs": "latest", "aws-sdk": "latest", "express": "latest", "body-parser": "latest" }, "scripts": { "start": "node app.js" } } Bad idea to do this for production environments
  13. 13. package.json (cont.) { "name": "Elastic-Beanstalk-Sample-App", "version": "0.0.1", "private": true, "dependencies": { "ejs": "2.3.3", "aws-sdk": "2.1.39", "express": "4.13.1", "body-parser": "1.13.2" }, "scripts": { "start": "node app.js" } } Always lock down versions of dependencies
  14. 14. npm-shrinkwrap.json { "name": "Elastic-Beanstalk-Sample-App", "version": "0.0.1", "dependencies": { "aws-sdk": { "version": "2.1.39", "from": "aws-sdk@latest", "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.1.39.tgz", "dependencies": { "sax": { "version": "0.5.3", "from": "sax@0.5.3", "resolved": "https://registry.npmjs.org/sax/-/sax-0.5.3.tgz" }, "xml2js": { "version": "0.2.8", "from": "xml2js@0.2.8", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.8.tgz" }, cont…
  15. 15. Sample application details How to configure and customize an environment using .ebextensions https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
  16. 16. options.config option_settings: aws:elasticbeanstalk:customoption: AlarmEmail: "nobody@amazon.com" aws:elasticbeanstalk:application:environment: THEME: "flatly" AWS_REGION: '`{ "Ref" : "AWS::Region"}`' STARTUP_SIGNUP_TABLE: '`{ "Ref" : "StartupSignupsTable"}`' NEW_SIGNUP_TOPIC: '`{ "Ref" : "NewSignupTopic"}`' aws:elasticbeanstalk:container:nodejs: ProxyServer: nginx aws:elasticbeanstalk:container:nodejs:staticfiles: /static: /static
  17. 17. Sample application details How to add additional AWS resources (e.g., Amazon DynamoDB, Amazon SNS, Amazon SQS, etc.) using .ebextensions https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html
  18. 18. resources.config Resources: StartupSignupsTable: Type: AWS::DynamoDB::Table Properties: KeySchema: HashKeyElement: {AttributeName: email, AttributeType: S} ProvisionedThroughput: {ReadCapacityUnits: 1, WriteCapacityUnits: 1} NewSignupQueue: Type: AWS::SQS::Queue NewSignupTopic: Type: AWS::SNS::Topic Properties: Subscription: - Endpoint: Fn::GetOptionSetting: {DefaultValue: nobody@amazon.com, OptionName: NewSignupEmail} Protocol: email - Endpoint: Fn::GetAtt: [NewSignupQueue, Arn] Protocol: sqs
  19. 19. resources.config (cont.) AllowSNS2SQSPolicy: Type: AWS::SQS::QueuePolicy Properties: PolicyDocument: Id: PublicationPolicy Statement: - Action: ['sqs:SendMessage'] Condition: ArnEquals: aws:SourceArn: {Ref: NewSignupTopic} Effect: Allow Principal: {AWS: '*'} Resource: Fn::GetAtt: [NewSignupQueue, Arn] Sid: Allow-SNS-SendMessage Version: '2008-10-17' Queues: - {Ref: NewSignupQueue}
  20. 20. Demo Application deployment
  21. 21. Best practices
  22. 22. Testing and tuning your application • Pick performance metrics you want to optimize for (e.g., latency, concurrent users, number of web requests, etc.) • Load test your application: • Start with autoscaling minimum and maximum of 1 to understand how your application degrades under an overload condition • Understand available metrics and how they correspond to your performance metric • Configure autoscaling to optimize for performance metrics: • Number of instances to add on scale out • Breach duration • Metric to scale on • Tune the back end (DynamoDB, RDS, etc.) for optimal performance; leave enough headroom for full scale out
  23. 23. Deployment option (rolling) Pros: • Deployments are fast (20-60 sec.) Cons: • Slower rollback because the previous application version must be redeployed • Possibility of state build-up on long-running environments
  24. 24. Deployment option (blue/green) Pros: • Fast rollback because the environment running the previous version has not been modified in any way • Ensures no state build up on environments Cons: • Deployments take longer than rolling deployments (2-5 min.) because a new environment must be created • Clients (i.e., mobile devices) might cache DNS addresses and not respect DNS TTL, resulting in staggered/non-deterministic traffic rollover to the new environment
  25. 25. Logs, metrics, and alarms • Enable log rotation to automatically publish logs to Amazon S3 • Understand metrics available for your environment and what they mean • Set up alarms to automatically monitor critical metrics and send notifications when metrics are outside normal operating range • Enable Amazon Route 53 health checks and alarms
  26. 26. Tag your environments • Makes it easy to find resources belonging to a given environment • Can be used to monitor costs associated with a given environment, or application, or both • Elastic Beanstalk automatically tags environments with: • Environment name • Environment ID
  27. 27. Demo Best practices
  28. 28. Customer story: Royal Caribbean Cruises Ltd.
  29. 29. Royal Caribbean Cruises Ltd. • Operates 43 ships with 6 more under construction contract and 2 more on firm order under 6 brands • Services 490 destinations on all 7 continents • 9,000 HTML pages served from the Royal Caribbean site alone • royalcaribbean.com launched using Elastic Beanstalk in March 2015 • 100 mm monthly page views during peak season • 6 mm monthly unique visitors during peak season • 40 mm page-view surge above average during peak
  30. 30. Historical challenges • On-premises: • High demand for limited development and test environments • Procurement dependencies, hardware failures, low resilience, fixed scale, high operational cost • Cloud Infrastructure as a Service (IaaS vs PaaS): • Learning curve and retooling is costly and time consuming: • It’s more complicated than a collection of cloud servers • Architecting an enterprise-grade stack requires many components working in concert: • Networking, security, provisioning, deployment mechanisms, configuration management, load balancing, autoscaling, fault tolerance and recovery, and monitoring
  31. 31. The case for Elastic Beanstalk • Elastic Beanstalk ̶ a key component of continuous delivery: • Reduces the cost, time, and risk of delivering regular, incremental value to users • Lower IT burden during and after delivery: • Mostly self-serve environments (dev, test, perf) • Automated provisioning, scaling, healing • Single pane of glass for managing the stack (Elastic Load Balancing, Amazon EC2, Auto Scaling, Amazon CloudWatch) • Environments just work…it’s very stable • Zero-downtime production deployments are fast and reliable • Technology enablement: • Empowers the Marketing team • Provides visibility into environments, health, performance, KPIs • Provides the ability to easily create and manage own environments for multiple projects and tracks
  32. 32. Environments on demand • Easily spin up identical or similar environment stacks for test cycles, parallel release tracks, and other projects • Different projects can have different environment requirements, yet follow a common paradigm • A few templates and a couple commands are all that you need Dev Dev2 Tst Tst2 Website brand 1 Dev Dev2 Dev3 Tst Tst2 Website brand 2 Tst3 Dev/test VPC Stage/prod VPC Stg Stg2 Preprd Prod Website brand 1 Stg Stg2 Stg3 Preprd Preview Website brand 2 Prod
  33. 33. Redis Labs Cache Cluster S3 Apache/ Tomcat Zone 1 Zone 2 ELB Zone 1 ELB Internet gateway AWS Direct Connect Private subnets Service APIs, Splunk Security layer Zone 2 ELB Zone 1 ELB Public subnets VPN fallback Security layer Zone 1 Zone 2 Royal Datacenter Apache/ Tomcat Zone 2 Application architecture Elastic Beanstalk
  34. 34. Automation AWS CloudFormation + AWS APIs + CI + Elastic Beanstalk • Use CloudFormation templates to create and manage environment configuration: • Nested for shared and environment-specific configurations • Use AWS APIs to script environment creation and updates • Use Jenkins for continuous integration and deployment to Elastic Beanstalk • Use Git for code and infrastructure configuration management (Elastic Beanstalk templates) • Use the Elastic Beanstalk console to monitor and troubleshoot • Automate everything for repeatability, reliability, and reportability: • Standardized configuration enforced • No room for human error • Rollbacks and auditing • Quick and easy AWS CloudFormation AWS APIs Jenkins CI Elastic Beanstalk
  35. 35. Design Code Build Test OperateRelease Deploy Develop Continuous integration Release cycles DevOps Automated builds, tests, and code scans Automated deployment and provisioning Automated load balancing, scaling, and cluster health management Git + Elastic Beanstalk + CloudFormation Continuous delivery
  36. 36. Results • Zero-downtime deployments • 30-minute deployments vs. up to 3 hours • Very stable under high load • One part-time resource to support all Elastic Beanstalk environments • In October, we will also launch the following on Elastic Beanstalk: • royalcaribbean.com.br • royalcaribbean.es • royalcaribbean-espanol.com • royalcaribbean.com.au • Mobile booking 83% Deployment time reduced by 0 Outages since March go live 75% Web app ops reduced by
  37. 37. Thank you!
  38. 38. Remember to complete your evaluations!

×