AWS Elastic Beanstalk - Running Microservices and Docker

Preview:

Citation preview

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

Adhiraj Singh | Sr. Product Manager | AWS Elastic Beanstalk

06/21/2016

AWS Elastic Beanstalk (EB)Running Microservices and Docker

Agenda

• Elastic Beanstalk vs DIY

• How to use Elastic Beanstalk

• Multi-Container Docker with AWS Elastic Beanstalk

• Recently added features

• Customer Feature - Sean O’Brien (Prezi)

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

What is Elastic Beanstalk?

AWS Elastic Beanstalk is an easy-to-use service for

deploying and scaling web applications and services.

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

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

Common Use Cases

• Websites

• API backends

• Mobile backends

• Asynchronous workers

Customers

Elastic Beanstalk Benefits

Fast & simple

to begin

Developer

productivity

Impossible

to outgrow

Complete

resource control

No additional charge to use.

You only pay for underlying AWS resources (i.e.: EC2 instances, S3, etc.)

How do I get started with Elastic Beanstalk?

Information required to deploy application

01

02

03

04

Region

Stack (container) type

Single InstanceLoad Balanced with

auto-scalingOR

Database (RDS) Optional

Your codeSupported Platforms

Building applications with Elastic Beanstalk

Service Repos:

/myapp

/myapp/browserClient

/myapp/browserServer

/myapp/androidUI

/myapp/api

/myapp/notifications

/myapp/adminPortal

Application: api

Environment

prod-api V1

Environment

dev-api V1.1

Environment

browserClient V2

Environment

browserClient V2.1

Environment

dev-api V1.2

Environment

browserClient V3

Application: browser

How to deploy applications

1. Via AWS Management Console

2. Via AWS Toolkit for Eclipse and Visual

Studio IDE

3. Via AWS SDK’s and CLI

4. Via EB command line interface

$ eb deploy

Deploy Sample Application (EB CLI)

Initial application deployment workflow

$ git clone https://github.com/awslabs/eb-node-express-sample.git

Download sample application02

$ eb init

Create your Elastic Beanstalk app03

Follow the prompts to configure the

environment04

05 Create the resources and launch the

application

$ eb create

$ pip install --upgrade awsebcli

Install the AWS Elastic Beanstalk

command line interface (EB CLI)

01

Update Sample Application (EB CLI)

Update application workflow

Update your code01

$ git add .$ git commit –m “v2.0”$ eb deploy

Add & commit code to repository02

Open application once deployment

completes.

03

$ eb open

Docker with AWS Elastic Beanstalk

Docker Platform Configurations

• Single Container Docker

• Multi-Container Docker

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

Multi Container: Dockerrun.aws.json

{"AWSEBDockerrunVersion": 2,"volumes": [

{"name": "node-app","host": {

"sourcePath": "/var/app/current/node-app"}

},{

"name": "tomcat-app","host": {

"sourcePath": "/var/app/current/tomcat-app"}

}],"containerDefinitions": [

{"name": "node-app","image": "node:0.12","essential": true,"memory": 128,"portMappings": [

{"hostPort": 80,"containerPort": 8000

}],"command": [

"/bin/bash","/usr/src/app/run.sh"

],"mountPoints": [

{"sourceVolume": "node-app","containerPath": "/usr/src/app"

}]

},{

"name": "tomcat-app","image": "tomcat:8.0","essential": true,"memory": 256,"portMappings": [

{"hostPort": 8080,"containerPort": 8080

}],"mountPoints": [

{"sourceVolume": "awseb-logs-tomcat-app","containerPath": "/usr/local/tomcat/logs"

},{

"sourceVolume": "tomcat-app","containerPath": "/usr/local/tomcat/webapps/ROOT","readOnly": true

}]

}]

}

Multi Container requires version 2

Multi Container with Elastic Beanstalk : Demo

Nginx Proxy ExampleCode at: https://github.com/awslabs/eb-docker-nginx-proxy

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.

New Features

Questions?

How to get in touch with the EB team?

AWS Elastic Beanstalk Forum:

https://forums.aws.amazon.com/forum.jspa?forumID=86

Twitter:

@aws_eb

Thank You!

Don’t Forget Evaluations!

Multi Container: Virtual Hosts ExampleCode 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

Multi Container:

Multiple Ports ExampleCode 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

Recommended