1. AWS Cloud Kata for Start-Ups and Developers
Hong
Kong
Getting Started with Serverless
and Container Architectures
Dickson Yue
Solutions Architect, AWS
2. AWS Cloud Kata for Start-Ups and Developers
Key take way
Deploy your Containers with ECS
Develop services with Lambda
Build your micro services architecture with Serverless
(Lambda) and Container (ECS)
3. AWS Cloud Kata for Start-Ups and Developers
Operational complexity - “I want to run some code in the cloud”
• …but ops are complicated, and I don’t have an ops guy
Undifferentiated instances - “I want flexibility to use the code I like”
• …but OS and runtime configuration? Don’t really care.
Capacity management concerns - “My business scales with users and requests”
• …but I don’t want a planning exercise to reserve and provision capacity
Low utilization but high scale - “I want infinite scale”
• …but I only want to pay for calls I actually make
Run some code
in the cloud
4. AWS Cloud Kata for Start-Ups and Developers
How do I choose?
• VMs
• “I want to configure machines,
storage, networking, and my OS”
• Containers
• “I want to run servers, configure
applications, and control scaling”
• Serverless
• “Run my code when it’s needed”
ECS
EC2
AWS Lambda
5. AWS Cloud Kata for Start-Ups and Developers
Amazon
Route 53User
Amazon
CloudFront
Web
RDS Master
(Multi-AZ)
Elastic
Load
Balancer
RDS Slave
(Multi-AZ)
Web
Availability Zone Availability Zone
6. AWS Cloud Kata for Start-Ups and Developers
Micro services
Amazon
Route 53User
Amazon
CloudFront
Static website
*.html, *.js *.css *.jpg *.mp4
S3
Web
RDS Master
(Multi-AZ)
RDS Slave
(Multi-AZ)
Zone A Zone B
DynamoDB
Fn1()
API
Gateway
Fn2() Fn3()
Redis MySQL
Web
RDS Master
(Multi-AZ)
RDS Slave
(Multi-AZ)
Zone A Zone B
EC2 Containter Serverless
Service Alpha Service Delta, Gamma Service Beta
8. AWS Cloud Kata for Start-Ups and Developers
Self managed EC2
Elastic Beanstalk
Elastic container service (ECS)
Deployment options
9. AWS Cloud Kata for Start-Ups and Developers
Server
Guest OS
Bins/Libs Bins/Libs
App2App1
Managing One Host is Straightforward
10. AWS Cloud Kata for Start-Ups and Developers
Managing a Fleet is Hard
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
Server
Guest OS
AZ 1 AZ 2
AZ 3
11. AWS Cloud Kata for Start-Ups and Developers
What is EC2 Container Service?
12. AWS Cloud Kata for Start-Ups and Developers
Cluster Management Made Easy
No cluster software to install and manage
Manages cluster state
Manages containers
Control and monitoring
Scale from one to tens of thousands of
containers
13. AWS Cloud Kata for Start-Ups and Developers
Designed for use with other AWS
services
Elastic Load Balancing
Amazon Elastic Block Store
Amazon Virtual Private Cloud
AWS Identity and Access Management
AWS CloudTrail
14. AWS Cloud Kata for Start-Ups and Developers
Key Components
Clusters
Containers
Task Definitions
Service
15. AWS Cloud Kata for Start-Ups and Developers
Typical User Workflow
I have a Docker
image, and I want to
run the image on a
cluster
16. AWS Cloud Kata for Start-Ups and Developers
Typical User Workflow
Push Image(s)
Amazon ECR
Docker Hub
Or
> docker build -t dicksonyue/aws-voting-app:ecsdemo .
> docker push dicksonyue/aws-voting-app:ecsdemo
17. AWS Cloud Kata for Start-Ups and Developers
Typical User Workflow
Create Task Definition Amazon ECS
Task Definition
- Image
- CPU, memory
- Port mapping
- CMD, ENV
> aws ecs register-task-definition --cli-input-json file://
ecs-task.json
19. AWS Cloud Kata for Start-Ups and Developers
Typical User Workflow
Run Instances EC2
Use custom AMI with
Docker support and
ECS Agent. Instances
will register with
default cluster.
> aws ecs create-cluster --cluster-name "ecs-demo"
> aws autoscaling create-launch-configuration --cli-input-json file://launch-config.json --
user-data file://userdata.txt
> aws autoscaling create-auto-scaling-group --cli-input-json file://auto-scaling-group.json
20. AWS Cloud Kata for Start-Ups and Developers
User data.txt
#!/bin/bash
echo ECS_CLUSTER=ecs-demo >> /etc/ecs/ecs.config
21. AWS Cloud Kata for Start-Ups and Developers
Cluster Management: Resource
Management
Docker
EC2 Instance
Docker
EC2 Instance
Docker
EC2 Instance
AZ 1 AZ 2
Cluster:ecs-demo
22. AWS Cloud Kata for Start-Ups and Developers
Typical User Workflow
Run Task
or
Create Service
Amazon ECS
Using the task definition
created above> aws ecs run-task --task-definition vote-app-task --
cluster ecs-demo
> aws ecs create-service --cli-input-json file://ecs-service.json
23. AWS Cloud Kata for Start-Ups and Developers
Cluster Management: Scheduling
Docker
Task
EC2 Instance
Container
Docker
Task
EC2 Instance
Container
Task
Container
Docker
EC2 Instance
Task
Container
AZ 1 AZ 2
24. AWS Cloud Kata for Start-Ups and Developers
Task vs Service
Task
• One time execute
• Batch job
Service
• One or different tasks (i.e. nodejs, ngnix)
• Task count (4 nodejs containers)
• Container and ELB port binding
• Auto scaling at task level
• Always on - Web application
Containers
25. AWS Cloud Kata for Start-Ups and Developers
Service
{
"cluster": "ecs-demo",
"serviceName": "vote-app-service",
"taskDefinition": "vote-app-task",
"loadBalancers": [
{
"targetGroupArn": "arn:aws:elasticloadbalancing:us-
west-2:179303575282:targetgroup/voting-app/99ffe4fab0a151e9",
"containerName": "kata-demo-container",
"containerPort": 8080
}
],
"desiredCount": 2,
"role": "ecsServiceRole”
}
Application load balancer
Container port
IAM Role
28. AWS Cloud Kata for Start-Ups and Developers
2) Con'nuous Scaling 1) No Servers to Manage
AWS Lambda automa-cally scales your
applica-on by running code in response to
each trigger. Your code runs in parallel and
processes each trigger individually, scaling
precisely with the size of the workload.
3) Subsecond Metering
With AWS Lambda, you are charged for
every 100ms your code executes and the
number of -mes your code is triggered.
You don't pay anything when your code
isn't running.
AWS Lambda automa-cally runs your code
without requiring you to provision or
manage servers. Just write the code and
upload it to Lambda.
Benefits of AWS Lambda
29. AWS Cloud Kata for Start-Ups and Developers
How Lambda works
S3 event
notifications
DynamoDB
Streams
Kinesis
events
Cognito
events
SNS
events
Custom
events
CloudTrail
events LambdaDynamoDB
Kinesis S3
Any custom
Redshift
SNS
Any AWS
30. AWS Cloud Kata for Start-Ups and Developers
AWS Lambda, API Gateway, and AWS IoT
regions
Available regions
Singapore
31. AWS Cloud Kata for Start-Ups and Developers
Lambda usage scenarios
32. AWS Cloud Kata for Start-Ups and Developers
Use case: Data processing
Example: Amazon S3 bucket triggers
Amazon S3 bucket events
Original object
Compressed object
1
2
3
AWS Lambda
33. AWS Cloud Kata for Start-Ups and Developers
Use case: Dynamic data ingestion
“I want to apply custom logic to process
content being uploaded to my data store”.
• PDF watermarking
• Image thumbnailing and transcoding
• Document metadata Indexing
• Log aggrega-on and filtering
• RSS feed processing
• Media content valida-on
34. AWS Cloud Kata for Start-Ups and Developers
Use case: Realtime data stream processing: Amazon Kinesis
“I want to apply custom logic to process logs
being uploaded through my Kinesis stream”.
• Client ac-vity tracking
• metrics genera-on
• data cleansing
• Log filtering
• indexing and searching
• Log rou-ng
35. AWS Cloud Kata for Start-Ups and Developers
Use case: mobile backend
1. AWS Mobile SDK + Amazon Cognito for mobile app
Or AWS IoT for devices
2. AWS Lambda runs the code
3. Amazon API Gateway (if you want your own endpoint)
4. Amazon DynamoDB holds the data
AWS Lambda
Amazon
DynamoDB
36. AWS Cloud Kata for Start-Ups and Developers
Use case: Serverless web apps
1. Amazon S3 for serving static content
2. AWS Lambda for dynamic content
3. Amazon API Gateway for https access
4. Amazon DynamoDB for NoSQL data storage
Dynamic content
in AWS Lambda
Data stored in
Amazon
DynamoDB
API GatewayStatic content in
Amazon S3
37. AWS Cloud Kata for Start-Ups and Developers
re:Invent 2015
• Python
• Scheduled functions
• Longer running times (5 min.)
• Versioning
Recent launches
Since re:Invent
• Higher code storage limits (from 5 GB to
75 GB)
• Custom VPC
• 1-minute schedules
• New regional launch
• Node.js 4.3.2
• 1-click CORs setup
• Stage variables
• Custom (Lambda) authorizers
• Builtin Swagger import/export
• AWS CloudFormation support for API
Gateway and versions
New!
39. AWS Cloud Kata for Start-Ups and Developers
Container
ECS
Cluster
Task & Service
AWS CLI or Console
Summary
Serverless
Lambda
Use cases
New features
40. AWS Cloud Kata for Start-Ups and Developers
Hong
Kong
Thank you