Sei sulla pagina 1di 70

ARC205

Born in the Cloud


Built like a Startup
Paul Underwood, Solution Architect, AWS
Keith Horwood, CEO and Founder, Polybit

November 29, 2016


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

What to Expect from the Session

How to think like a startup when deploying


your next workload on AWS.
Whether you work for an enterprise or a
small business.

What to Expect from the Session

My expectations:
100-level AWS
constructs
Familiarity with
AWS services

What to Expect from the Session

My expectations:
100-level AWS
constructs
Familiarity with
AWS services

Architectures we
will cover:
N-tier
Containerized
Serverless

Implications on:
Cost
Performance
Team structure

What to Expect from the Session

My expectations:
100-level AWS
constructs
Familiarity with
AWS services

Architectures we
will cover:
N-tier
Containerized
Serverless

Implications on:
Cost
Performance
Team structure

Deep dive w/
Polybit:
Practical
DevOps
techniques in an
increasingly
serverless world

What are startups thinking about?

Expecting
scale

Focus on
features

Lean IT
department

Low cost ==
Long runway

Isn't everybody?

What else are we thinking about?

Reliability

Performance

Cost efficiency

Security

Can building like a startup align these goals?

Expecting
scale

Focus on
features

Lean IT
department

Reliability

Performance

Cost efficiency

Low cost ==
Long runway

Security

OK, so how have people done


this historically?

Using these kinds of frameworks

How? Monolithic/N-tier architectures

Load Balancer

App Server

DB Master
Data Center 1

App Server

DB Stby
Data Center 2

Your infrastructure provider

How do startups do this on AWS?


git clone git://myrepo && cd myrepo
eb init
eb create prod
pg_restore -v h mydb.rds.amazonaws.com latest.dump
eb setenv SHARED_KEY_OF_SOME_SORT=34dsa2x32vxj
/// Changes
eb create test
git add . && git commit -m profound change
eb deploy
/// Test
eb switch prod && eb deploy

This gets us VM-based N-tier on AWS


Elastic Load
Balancing

EC2

EC2

RDS

Stby

Availability Zone A

Availability Zone B

ExampleApp-Prod
ExampleApp-Test

Plus some significant benefits


AWS Security
Identity and access
management
VPC networking

Amazon CloudWatch
Service-wide
resource
monitoring
Log management

Specialist services
Block/object
storage
Caching
DNS

ELB

EC2

EC2

RDS

Stby

Availability Zone A

Availability Zone B

ExampleApp-Prod
ExampleApp-Test

AWS Elastic Beanstalk Making N-Tier Easier


The quickest path to
best practices

AWS Security
Identity and access
management
VPC networking
Amazon CloudWatch
Service-wide
resource
monitoring
Log management

Specialist Services
Block/Object
Storage
Caching
DNS

ELB

EC2

EC2

RDS

Stby

Availability Zone A

Availability Zone B

ExampleApp-Prod
ExampleApp-Test

AWS Elastic Beanstalk


Builds you into best
practices from the start
Integrates with
developer workflows
Use the Elastic
Beanstalk Command
Line Interface

What does this cost?


Development-grade stack

Production-grade stack

Tier

Spec

Monthly
Cost

Tier

Spec

Monthly
Cost

Load
Balancer

1x

$18.30

Load
Balancer

1x

$18.30

Application
Server

1 x t2.micro

$9.52

Application
Server

2x
m4.large

$121.18

Database
Server

1 x t2.micro
100 GB

$23.95

Database
Server

2x
m4.large
100 GB

$198.93

Total Monthly

$51.77
Total Monthly

$320.11

Containerized Architectures

Containers in theory look like conventional N-tier


VM-based N-tier

Container-based N-tTier

ELB

Web
Web
Server
Server

Web
Web
Server
Server

Stby

DB

Hypervisor

Cont.
Instances
Cont.
Cont.Instances
Instances

In practice, leverage the platform


VM-based N-tier

Amazon ECS-based N-tier


Application
Load Balancer

ELB

Web
Web
Server
Server

Web
Web
Server
Server

Stby

DB

Hypervisor

RDS Standby

RDS Master

Cont.
Instances
Cont.
Cont.Instances
Instances

How startups are building containers on AWS


## set up
aws ecs get-login
docker build t <tagName> .
docker tag <tagName>:latest <repoUrl>/<tagName>:latest
ecs-cli configure --region us-west-2 --cluster <clusterName>
ecs-cli up --keypair <keyPairID> --capability-iam --size 2 --type
## auto-generate service and task definition, no ALB, no ASG
ecs-cli compose service create --file docker-compose.yml
ecs-cli compose service start
## instead, use ECS to define more sophisticated services
aws ecs create-service --service-name <serviceName> --cli-input-json
file://sophisticated-service-def.json

What does ECS give us?


Application
Load Balancer

Container Registry
Dockerfiles
docker-compose.yml
Services/tasks
*Amazon RDS managed
RDS Standby

Scheduler

RDS Master

Cont.
Instances
Cont.
Cont.Instances
Instances

But what about?


Application
Load Balancer

Service discovery

Container Registry
Dockerfiles
docker-compose.yml
Services/tasks

Container instance
scaling
RDS Standby

Scheduler

Cont.
Instances
Cont.
Cont.Instances
Instances

Container-level
logging

What does this cost?


Production-grade
Amazon EC2 stack
(40%
Tier utilization)
Spec

Production-grade ECS stack


(80% utilization)
Monthly
Cost

Tier

Spec

Monthly
Cost

Load
Balancer

1x

$18.30

Load
Balancer

1x

$18.30

Application
Server

2x
m4.large

$121.18

Container
Instances

2x
m4.large

$121.18

Database
Server

2x
m4.large
100 GB

$198.93

Database
Server

2x
m4.large
100 GB

$198.93

$320.11

Total Monthly

Total Monthly

$320.11

N-tier/Container DevOps

The Stack Challenge

Opinion time:
Traditional VM and container
architectures are rooted in
emulating classic physical
servers

and therefore inherit the Stack Challenge


Whose responsibility is?
Server-level configuration:

Packages/dependencies
Users/groups
Build sources
Files
Bootstrapping commands
Services
Security

Cluster-level configuration

Container instances
Supporting core services

The Stack Challenge


Whose responsibility is?
Server-level configuration:

Packages/dependencies
Users/groups
Build sources
Files
Bootstrapping commands
Services
Security

Cluster-level configuration

Container instances
Supporting core services

Tooling can get you so far

Eventually, you need DevOps staff

Why???

!=
Developer

DevOps
Engineer

What is that rushing sound?


Feature 2
Feature 1
Feature 0
Dev

Test

Ops

Main.

Meanwhile, back at the lab

Thinking big, inventing, simplifying


Traditional VM and container architectures are rooted in
emulating classic physical servers.
Why should anyone care about servers?
Feature development is far more valuable than solving
server-centric stack challenges.
Why cant things just scale automatically?

Monolithic

1946
ENIAC

Containers

1979
chroot process isolation

2013
Docker

Server-Centric
Architecture

Historical perspective

Cloud VMs
2006 2009 2010
EC2 ELB RDS

Whats next?
Tipping point for modern startup adoption

Serverless

A serverless web application architecture


Angular/SPA

Images/Video

Desktop

*aaS

Mobile

Amazon
CloudFront/
Amazon S3

HTML/CSS/JS

Static Asset Requests

A serverless web application architecture


Angular/SPA

Images/Video

Amazon
CloudFront/
Amazon S3

Desktop

api.example.com
*aaS

Amazon
API Gateway

Mobile

Static Asset Requests

HTML/CSS/JS

AWS Lambda

Dynamic Requests

A serverless web application architecture


Angular/SPA

Images/Video

Amazon
CloudFront/
Amazon S3

Desktop

api.example.com

Static Asset Requests

HTML/CSS/JS

AWS Lambda

Dynamic Requests

*aaS

Amazon
API Gateway

Persistence/Database
Mobile
Amazon
DynamoDB

How to do this on AWS?

Flourish

What does this cost?


Cost per user/month:

Imagine the following daily


customer usage pattern:
Assumption
Total Pages / Day
Avg Size of Page
API Requests / Page
Avg size of API Req
DB Ops per API Req
Storage (per month)

Unit
10
200
kb
5
4
kb
2 1r/1w
500
kb

Charge
CloudFront Data Transfer
CloudFront Request Pricing
S3 Request Pricing (15% cache-hit)
S3 Data Transfer
API Gateway Data Transfer
API Gateway Request Pricing
Lambda Request Pricing
Lambda Duration Cost
DynamoDB IO Pricing
DynamoDB Storage
Total Monthly Cost / User

Monthly Cost
0.0051
0.0003
0.00102
0.004335
0.00054
0.00525
0.0003
0.000312
0
0.000125
$0.017282

Microservice thinking

Through a microservice lens on Day 0


Angular/SPA

Images/Video

CloudFront/S3

HTML/CSS/JS

AWS Lambda
API Gateway

DynamoDB

Service 0:
CoreSite

Dev

Test

Ops

Main.

As microservice complexity scales


Angular/SPA

Images/Video

CloudFront/S3

Service 0:
CoreSite FrontEnd

HTML/CSS/JS

Dev

Test

Ops

Main.

AWS Lambda
API Gateway

DynamoDB

Service 1:
CoreSite API
Service
Mitosis @ 2
Pizzas

and so on

Let your teams pick the right tools for the job
Service 0
Dev

Test

Ops

Main.

Service 1
Dev

Test

Ops

Main.

Service 2
Dev

Test

Ops

Main.

Let your teams pick the right tools for the job
Core Svcs

Route 53
DNS

Service 0
Dev

Test

Ops

Main.

Service 1
Dev

Test

Ops

Main.

API Gateway

Service 2
Account Mgmt

Dev

Test

Ops

Main.

Let your teams pick the right tools for the job
Core Svcs

Route 53
DNS

Service 0
Dev

Test

Ops

Main.

Service 1
Dev

Test

Ops

Main.

API Gateway

Big Data

Mobile/UX

Amazon
Redshift

AWS
Mobile Hub

Amazon EMR

Amazon
Mobile Analytics

Amazon
Kinesis

Amazon
Cognito

Service 2
Account Mgmt

Dev

Test

Ops

Main.

So, we understand N-tier and container DevOps


Core Svcs

Service 0
Dev
Ops

Route 53
DNS

API Gateway

Account Mgmt

Mobile/UX

Amazon
Redshift

AWS
Mobile Hub

Amazon EMR

Amazon
Mobile Analytics

Amazon
Kinesis

Amazon
Cognito

Dockerized
Service
Test

Main.

Dev

Test

Ops

Main.

Service 1
Dev

Test

Ops

Main.

VM Based N-Tier
Service
Service 2
Dev
Dev

Big Data

Test

Test

OpsMain.
Ops

Main.

What about DevOps in a serverless world?


Core Svcs

Serverless
Service
0
Big Data

Mobile/UX

Service
Dev
Ops

Route 53
DNS

Test
Main.

Dev

Ops

Test
Main.

Service 1
Dev

Test

Ops

Main.

API Gateway

Amazon
Redshift

AWS
Mobile Hub

Amazon EMR

Amazon
Mobile Analytics

Amazon
Kinesis

Amazon
Cognito

Service 2
Account Mgmt

Dev

Test

Ops

Main.

Unlocking Practical
Serverless Development

So you want to go serverless

Scalability

Decreased cost

Organizational
Compartmentalization

UNIX philosophy

AWS: The system architecture of the web

Organizational tooling for serverless


-

Sharing
Discovery
Environments
Deployment pipelines
Microservice versioning
Legacy app interoperability

Discover, create, manage services


https://github.com/poly/stdlib
Install CLI
$ npm install lib g

Test Service Locally


$ f .

Initialize Workspace
$ lib init

Deploy Service [dev]


$ lib up dev

Create Service
$ lib create

Test Service Remotely


$ f username/service@dev

Discover, create, manage services


https://stdlib.com/search

Sharing and discovery

Client Request
https://f.yourdomain.com/your-service

DNS
(Route 53)

Gateway
(API Gateway)

your-service
(Lambda)

Environment and deployment


.env

MY_VARIABLE=test
STRIPE_API_KEY=watlol
DATABASE_URL=localhost

index.js
// load .env files
require(dotenv);
const stripe = require(stripe);
// do something
process.env.STRIPE_API_KEY

Environment and deployment


files
-

package.json
.dev.env
.staging.env
.prod.env
.gitignore
index.js

deploy
$ deploy-command --env prod

- package.json
- .env
- index.js

Environment and deployment


deploy
$ deploy-command --env prod

- package.json
- .env
- index.js

your-service_prod
(Lambda)

Microservice versioning

Client Request
your-service/VERSION

your-service:VERSION
(Lambda)

Microservice versioning
deploy

$ deploy-command --version VER

{Publish: true}
your-service:Number
(Lambda)

{Version:
Number}

createAlias
VER :: Number

Microservice versioning
deploy

$ deploy-command --version 1.0.0

{Publish: true}
your-service:NUMBER
(Lambda)

{Version:
NUMBER}

Mapping:
1.0.0 :: Number

Microservice versioning
Client Request
your-service/VERSION

Gateway
(Elastic Beanstalk)
DNS
(Route 53)

your-service
(Lambda)
Version Mapping
(DynamoDB)

Legacy app interoperability


aws-sdk

http

lambda.invoke()

f.yourdomain.com/()

Organizational tooling for serverless


-

Sharing
Discovery
Environments
Deployment pipelines
Microservice versioning
Legacy app interoperability

Organizational tooling for serverless

Route 53

EBS

API Gateway

DynamoDB

Lambda

Node.js: dotenv
CLI tools...

One organizational solution


https://github.com/poly/stdlib
Test Service Locally
$ f .

Deploy Service [dev]


$ lib up dev
Test Service Remotely
$ f username/service@dev

Sharing
Discovery
Environments
Deployment pipelines
Microservice versioning
Legacy app interoperability

Your Library for Microservices


https://stdlib.com/reinvent-2016
@polybit
@keithwhor

Final thought

A well-defined microservice implies its own architecture

Expecting
scale

Focus on
features

Lean IT
department

Reliability

Performance

Cost efficiency

Low cost ==
Long runway

Security

Thank you!
Paul Underwood paulu@amazon.com
Keith Horwood keith@polybit.com
Please dont forget to fill out your survey!

Potrebbero piacerti anche