You will learn:
• How to use Elastic Beanstalk
• How to run Single and Multi-Container Docker with AWS Elastic Beanstalk
• Best Practices running AWS Elastic Beanstalk
2. Agenda
• Overview
• Elastic Beanstalk vs DIY
• How to use Elastic Beanstalk
• Single and Multi-Container Docker with AWS Elastic Beanstalk
• Best Practices
3. Developer challenges
• Complexity of deploying code, provisioning
and managing infrastructure
• Expertise and time needed to manage and
configure servers, databases, load
balancers, firewalls, and networks
• How to automate application scaling
• Lack of consistency across teams
4. What is Elastic Beanstalk?
AWS Elastic Beanstalk is an easy-to-use service for
deploying, scaling, and managing web applications and
services.
5. AWS Elastic Beanstalk vs. Do It Yourself
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.
Focus on building your
application
Provided by you
Provided and managed by AWS Elastic Beanstalk (EB)
On-instance configuration
6. AWS Elastic Beanstalk vs. Do It Yourself
• Preconfigured Infrastructure
• Single Instance (Dev, Low Cost)
• Load Balanced, Auto Scaling (Production)
• Web & 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.: youapp.regionx.elasticbeanstalk.com)
Infrastructure stack
7. Elastic Beanstalk benefits
Fast & simple
to begin
Developer
productivity/agility
Impossible
to outgrow
Complete
resource control
No additional charge to use Elastic Beanstalk.
You pay only for underlying AWS resources (i.e., EC2 instances, S3, etc.)
10. Information required to deploy application
01
02
03
04
Region
Stack (container) type
Single Instance
Load Balanced
with Auto ScalingOR
Database (RDS)
Your code
Optional
Supported Platforms
Custom Platforms
Create and use your own custom
platform
12. How to deploy applications
1. Via AWS Management Console
2. Via AWS Toolkit for Eclipse and Visual
Studio IDE
3. Via AWS SDKs and CLI
4. Via EB command line interface
$ eb deploy
13. Deploy sample application (EB CLI)
Initial application deployment workflow
$ git clone
https://github.com/awslabs/eb-
node-express-sample.git
Download sample application2
$ eb init
Create your Elastic Beanstalk app3
Follow the prompts to configure the
environment
4
5 Create the resources and launch the
application
$ eb create
$ pip install --upgrade awsebcli
Install the AWS Elastic Beanstalk
command line interface (EB CLI)
1
18. Multi Container: Architecture
• Each environment has its own ECS Cluster
• Supports a single ECS Task definition per environment
• The ECS Task is defined in the Dockerrun.aws.json file
• Uses a flood scheduling mechanism
• Provides out of the box auto scaling for ECS Tasks
Elastic Beanstalk Environment
Auto Scaling Group / ECS Cluster
Instance 1 Instance 2
app1.elasticbeanstalk.com
Elastic Load
Balancing
Container 2Container 1
Container 3
Container 2Container 1
Container 3
22. Multi Container with Elastic Beanstalk
Multiple Ports Example
Code at: https://github.com/awslabs/eb-docker-multiple-ports
Elastic Beanstalk Environment
Auto Scaling Group / ECS Cluster
Instance 1 Instance 2
Node.js Node.js
Tomcat
80
8080 Tomcat
app1.elasticbeanstalk.com:80
app1.elasticbeanstalk.com:8080
Elastic Load
Balancing
23. Multi Container with Elastic Beanstalk
Virtual Hosts Example
Code at: https://github.com/awslabs/eb-docker-virtual-hosting
Elastic Beanstalk Environment
Auto Scaling Group / ECS Cluster
Instance 1 Instance 2
80
Container 1
Container 2
Nginx
Container 1
Container 2
Nginx
container1.app1.elasticbeanstalk.com
container2.app1.elasticbeanstalk.com
Elastic Load
Balancing
24. Benefits of using Multi-Container Docker with
Elastic Beanstalk
• Automation of capacity provisioning, load balancing,
scaling, and application health monitoring
• One stop management of your application in an
environment that supports range of services that are
integrated with Elastic Beanstalk, including but not
limited to VPC, RDS, and IAM.
26. Deployment options
* Default method ^ ”All at Once” Method used
Environment Type Deployment category Method
All at Once*
Immutable (New)
Disabled*^
Immutable (New)
All at Once
Rolling*
Rolling with additional batch
Immutable
Disabled^
Rolling based on Health*
Rolling based on Time
Immutable
Single Instance
Load Balanced/Auto-Scaled
Application
Platform/Configuration
Application
Platform/Configuration
27. Application deployment options
Method Impact of failed deployment
Deploy
Time
Zero
Downtime
No DNS
Change
Rollback
process
Code
Deployed
To
All at Once¬ Downtime ¹ X ü Re-deploy Existing
instances
Rolling Single batch out of service. Any
successful batches prior to
failure running new application
version
¹¹♦ ü ü Re-deploy Existing
instances
Rolling with
additional batch
Minimum if first batch fails,
otherwise similar to Rolling
¹¹¹♦ ü ü Re-deploy New &
existing
instances
Immutable¬ Minimal ¹¹¹¹ ü ü Re-deploy New
instances
Blue/Green Minimal ¹¹¹¹¹ ü X Swap URL New
instances
¬ Options available for both Single Instance and Load Balanced/Auto-Scaled Environments ♦ Varies depending on instance batch size
28. Managed Platform Update
Configure your environment to automatically upgrade to the latest
version of a platform during a scheduled maintenance window.
• Permissions
• Maintenance Window
• Minor and Patch Updates
Key benefits:
• Automated Upgrades
• No/Minimal downtime
• No/Minimal impact on capacity
• Flexibility of manual updates
• Instance replacement
30. Logs, Metrics, & Alarms
• Enable log rotation to automatically publish logs to S3.
• 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
• CloudWatch Log streaming to stream logs in real time from Elastic
Beanstalk managed EC2 instance to CloudWatch
31. Other tips
Tag your environments
• Resource discoverability, cost monitoring, access control
• Elastic Beanstalk automatically tags environments
Application version lifecycle management:
• Automate application version cleanup
• Does not apply to deployed versions
32. Custom Platform
• Create and manage your own custom Elastic Beanstalk
platforms
• Get greater control over the AMI, metadata, and
configuration
• Enforce and manage standardization/best practices across
environments (without the need for .ebextensions)
33. Custom Platform
Examples:
• Create your own platforms on Ubuntu or Red Hat Enterprise
• Customize your instances with languages/frameworks currently not
supported by Elastic Beanstalk e.g. Rust, Sinatra etc.
• Create your own platform that uses encrypted AMIs or custom disk
layouts e.g. multiple volumes, EFS mounts etc.