Microservices and API Gateways
in the AWS Cloud
Jean-Pierre Le Goaller
Senior Manager of Solutions Architecture
Amazon Web Services
Davide Gallo
Enterprise Accounts Director
Amazon Web Services
Agenda
1.  Current Trends in IT
2.  The case of microservices
3.  Microservices on AWS
4.  Hybrid Architectures
Software and Internet-enabled disruption
Darwinian survival principles
Established and well capitalized businesses are no longer insulated from
the disruptive market forces that technology advances have enabled.
Goliath has never been more vulnerable.
“It is not the strongest of the species
that survives, nor the most intelligent
that survives. It is the one that is
most adaptable to change.”
Charles Darwin (1809 – 1882)
On-premises to Cloud Computing
Waterfall to Agile Development Process
Monolithic Architecture to Microservices
The case for microservices
Monolith	
Microservices
Architecture
developers customers
releasetestbuild
plan monitor
delivery pipeline
feedback loop
Software development lifecycle
Minimize the total time through the loop
Monolith development lifecycle
developers
releasetestbuild
delivery pipeline
monolithic
app
Microservice development lifecycle
developers delivery pipelinesservices
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
releasetestbuild
Microservices
Single-Purpose
Connected through APIs
Highly decoupled
Decouple into small building blocks
The looser they are coupled,
the bigger they scale,
the more fault tolerant they get.
The less dependencies,
the faster you innovate.
•  100s of teams / startups
•  all iterating at once
•  towards specific metrics & performance
•  using lean principles & agile development
100s of Services…
LEAN
Experiment
Measure and Learn
Iterate at speed
1
2
3
CONTINUOUS
DEPLOYMENT
SMALL, FREQUENT CHANGES
CONSTANTLY INTEGRATING INTO
PRODUCTION.
= 50 million deployments a year
Thousands of teams
× Microservice architecture
× Continuous delivery
× Multiple environments
11.6s
Average time
between
deployments
(weekday)
1,079
Max number of
deployments in
a single hour
(or approx
every 3
seconds)
30,000
Max number of
instances
simultaneously
receiving a
deployment
Speed of deployments at amazon.com
~0.001%
Software
deployments
cause an
outage
Microservices on AWS
AWS Lambda
Evolution towards microservices
Lines
of
Code
EC2
AWS Elastic Beanstalk
Amazon EC2
EC2 Container Service
10,000s to 1,000,000s 100s to 1,000s 10s to 100s
Virtual Machines Containers Serverless
Deploying Microservices on Amazon EC2
Best practices:
•  Single service per host
•  Start with small instance sizes
•  Leverage AWS Auto-Scaling
and AWS Elastic Load
Balancing
•  Automate provisioning:
•  CloudFormation
•  Automated AMI factory
•  Configuration Management etc…
Auto Scaling group
EC2 Instance EC2 Instance EC2 Instance
Region
Elastic Load
Balancing
“Bring Your Own Code”
Your code
HTTP server
Application server
Language interpreter
Operating system
Host and Hypervisor
You focus on building
your application
Deploying Microservices on Amazon Elastic Beanstalk
AWS Elastic Beanstalk provisions:
•  Load balancing
•  Auto-scaling groups
•  Security groups
•  DNS
•  Managed Relational Database
Managed Platform: AWS provisions the environment
Deploying Microservices with Containers
Recommendations:
•  Multiple services per host
•  Use larger hosts with more CPU/
RAM
•  Use a container management
framework that removes
operational burden
region
Guest OS
Bins/Libs
Bins/
Libs
App2App1
EC2 Instance
Elastic Load
Balancing
Elastic Load
Balancing
API
Gatewa
y
API
Gatewa
y
Amazon EC2 Container Service
•  Supports Docker containers
•  Runs on EC2 in your VPC
•  Manages cluster resources
•  Flexible scheduler built in or bring
your own
•  Integrates with ELB, EBS, IAM
•  Amazon EC2 Container Registry
Unaddressed Management Issues
We’re still managing hosts
•  OS Patches
•  Host security
•  Host resource management
•  Scaling policy tweaks
•  Redundancy/Resiliency/Failover
« No Server is Easier to Manage
Than “No Server” »
Werner Vogels, Amazon CTO
•  Servers:
•  No visibility of underlying servers, storage and networking
•  Operating System
•  No need to select, configure, administer or patch the OS
•  Capacity
•  Elastic and (virtually) unlimited
•  Availability
•  Service is natively replicated and highly-available across multiple
Availability Zones
An Amazon definition of “Serverless”
Continuous
scaling
No servers to
manage
Never pay for idle
– no cold servers
(only happy
accountants)
Benefits of AWS Lambda
AWS Lambda Use Cases
Run code without servers. Pay only for the compute time you consume. Be happy.
Triggered by events or called from APIs:
•  PUT to an Amazon S3 bucket
•  Updates to Amazon DynamoDB table
•  Invoked by an API Gateway endpoint
•  Mobile app back-end call
•  And many more…
Makes it easy to:
•  Perform real-time data processing
•  Glue and choreograph systems
•  Build scalable back-end services
AWS Lambda: No Infrastructure to Manage
•  Run functions for up to 5 minutes
•  Event-driven or scheduled
•  Lambda handles:
•  Capacity
•  Scaling
•  Deployment
•  Monitoring
•  Logging
•  Web service front-end
•  Security patching
Region
AWS
Lambda
Function
AWS
Lambda
Function
AWS
Lambda
Function
AWS
Lambda
Function
API
Gateway
Pay-per request
•  Buy compute time in
100 ms increments for
21 microcents
•  Request charge of 20
microcents
•  No hourly, daily, or
monthly minimums
•  No per-device fees
Free Tier
1 million requests and 400,000 GBs of compute
every month, every customer
Never pay for idle!
Using AWS Lambda
Bring your own code
•  Node.js, Java, Python
•  Bring your own libraries
(even native ones)
Simple resource model
•  Select power rating from
128 MB to 1.5 GB
•  CPU and network allocated
proportionately
•  Reports actual usage
Flexible authorization
•  Securely grant access to
resources, including VPCs
•  Fine-grained control over
who can call your functions
Flexible use
•  Call or send events
•  Integrated with other AWS
services
•  Invoke from API Gateway
Using AWS Lambda
Programming model
•  AWS SDK built in (Python
and Node.js)
•  Eclipse plugin (Java)
•  Lambda is the “webserver”
•  Use processes, threads, /
tmp, sockets normally
Stateless
•  Persist data using Amazon
DynamoDB, S3, or
ElastiCache
•  No affinity to infrastructure
(can’t “log in to the box”)
Authoring functions
•  Author directly using the
console WYSIWYG editor
•  Package code as a .zip and
upload to Lambda or S3
•  Plugins for Eclipse and
Visual Studio
•  Command line tools
Monitoring and logging
•  Built-in metrics for requests,
errors, latency, and throttles
•  Built-in logs in Amazon
CloudWatch Logs
AWS Lambda Scaling
•  Lambda scales to match
the event rate
•  Don’t worry about over or
under provisioning
•  Pay only for what you use
Business Logic
AWS

Lambda
AWS Lambda

Functions
HTTPS

REST
API Call
API
Gateway
Benefits using an API Gateway
Create a unified API
front end for
multiple
microservices
DDoS protection
and throttling for
back-end systems
Authenticate and
authorize requests
Logging
Analytics
API Gateway as a front-end to APIs
Internet
Mobile Apps
Websites
Services
API
Gateway
AWS Lambda
functions
Elastic
Beanstalk
Endpoints on
Amazon EC2
On-Premises
APIs
EC2 Container
Service
Amazon
CloudFront
Web apps with API Gateway
Dynamic content
in AWS Lambda
Data stored in
Amazon
DynamoDB
API GatewayStatic content in
Amazon S3
API
Gateway
Amazon Cognito
API Gateway
Lambda
Lambda
Lambda
MOBILE DEVICE
 MOBILE BACKEND
DATA AND CONTENT
ANALYTICS
NOTIFICATIONS
S3
DynamoDB
Mobile Analytics
SNS
Mobile Application with API Gateway
λ
λ λ
API Gateway
λ
λ
λ λ
Bucket Usage

Table
Media Metadata
Table
User Stat
Table
User

Location
Table
λ
λ
λ
Amazon Cognito

Identity Broker
Amazon Cognito

Sync Store
Amazon

SNS
Amazon

Kinesis
Media

Bucket
Log
Table
λ
λ λ
λ
λ
λ λ
λ
λ
λ
Microservice Architecture
λλ λλ
λλ λλ λ
λ
API
Gateway
API
Gateway
region
Leveraging API Gateways
for Hybrid Architectures
AWS Virtual Private Network (IPSec VPN)!
Virtual
Gateway
Corporate 
data center
Users
Data center router
Servers
Internet
IPSec VPN
VPC Subnet
Availability Zone
Security Group
VPC Subnet
Availability Zone
Security Group
AWS Direct Connect!
Virtual
Gateway
Corporate 
data center
Users
Data center router
Servers
VPC Subnet
Availability Zone
Security Group
VPC Subnet
Availability Zone
Security Group
Customer 
router
AWS Direct Connect
LocaBon
AWS Direct Connect
routers
API Gateway as a front-end to cloud intranet apps!
Intranet Apps
API
Gateway
AWS Lambda
functions
Elastic
Beanstalk
Endpoints on
Amazon EC2
EC2 Container
Service
Corporate
Network
AWS region!
Private!
connection!
Your data center!
Internet!
In-house apps!
API
Gateway
Cloud Apps!
API
Gateway
API Gateway for hybrid workloads!
AWS region!
Private!
connection!
Your data center!
Internet!
API
Gateway
In-house apps! Cloud Apps!
API
Gateway
API Gateway for hybrid workloads!
AWS region!
Private!
connection!
Your data center!
Internet!
API
Gateway
In-house apps!
Cloud Apps!
API
Gateway
API Gateway for hybrid workloads!
AWS region!
Private!
connection!
Your data center!
Internet!
API
Gateway
In-house apps!
Cloud Apps!
API
Gateway
API Gateway for hybrid workloads!
Actions
Lambda SNS SQS
Serverless
Services
(Direct Integration)
S3 KinesisDDB
Hybrid IoT Architecture
RDS
Redshift
EC2
Rest of AWS
EMR
Machine
Learning
IoTThings
Serverless
IoT Service
API
Gateway
Lambda
Hybrid IoT Architecture
EC2
API
Gateway
IoTThings
On Prem
Recap
1.  Current Trends in IT
2.  The case for microservices
3.  Microservices on AWS
4.  Hybrid Architectures
JP Le Goaller
AWS Solutions Architecture
jplg@amazon.com
@jplegoal

2016-06 - Design your api management strategy - AWS - Microservices on AWS

  • 1.
    Microservices and APIGateways in the AWS Cloud Jean-Pierre Le Goaller Senior Manager of Solutions Architecture Amazon Web Services Davide Gallo Enterprise Accounts Director Amazon Web Services
  • 2.
    Agenda 1.  Current Trendsin IT 2.  The case of microservices 3.  Microservices on AWS 4.  Hybrid Architectures
  • 3.
  • 4.
    Darwinian survival principles Establishedand well capitalized businesses are no longer insulated from the disruptive market forces that technology advances have enabled. Goliath has never been more vulnerable. “It is not the strongest of the species that survives, nor the most intelligent that survives. It is the one that is most adaptable to change.” Charles Darwin (1809 – 1882)
  • 5.
  • 6.
    Waterfall to AgileDevelopment Process
  • 7.
  • 8.
    The case formicroservices
  • 9.
  • 10.
    developers customers releasetestbuild plan monitor deliverypipeline feedback loop Software development lifecycle Minimize the total time through the loop
  • 11.
  • 12.
    Microservice development lifecycle developersdelivery pipelinesservices releasetestbuild releasetestbuild releasetestbuild releasetestbuild releasetestbuild releasetestbuild
  • 13.
  • 14.
    Decouple into smallbuilding blocks The looser they are coupled, the bigger they scale, the more fault tolerant they get. The less dependencies, the faster you innovate.
  • 15.
    •  100s ofteams / startups •  all iterating at once •  towards specific metrics & performance •  using lean principles & agile development 100s of Services…
  • 16.
  • 17.
  • 18.
    = 50 milliondeployments a year Thousands of teams × Microservice architecture × Continuous delivery × Multiple environments
  • 19.
    11.6s Average time between deployments (weekday) 1,079 Max numberof deployments in a single hour (or approx every 3 seconds) 30,000 Max number of instances simultaneously receiving a deployment Speed of deployments at amazon.com ~0.001% Software deployments cause an outage
  • 20.
  • 21.
    AWS Lambda Evolution towardsmicroservices Lines of Code EC2 AWS Elastic Beanstalk Amazon EC2 EC2 Container Service 10,000s to 1,000,000s 100s to 1,000s 10s to 100s Virtual Machines Containers Serverless
  • 22.
    Deploying Microservices onAmazon EC2 Best practices: •  Single service per host •  Start with small instance sizes •  Leverage AWS Auto-Scaling and AWS Elastic Load Balancing •  Automate provisioning: •  CloudFormation •  Automated AMI factory •  Configuration Management etc… Auto Scaling group EC2 Instance EC2 Instance EC2 Instance Region Elastic Load Balancing
  • 23.
    “Bring Your OwnCode” Your code HTTP server Application server Language interpreter Operating system Host and Hypervisor You focus on building your application Deploying Microservices on Amazon Elastic Beanstalk
  • 24.
    AWS Elastic Beanstalkprovisions: •  Load balancing •  Auto-scaling groups •  Security groups •  DNS •  Managed Relational Database Managed Platform: AWS provisions the environment
  • 25.
    Deploying Microservices withContainers Recommendations: •  Multiple services per host •  Use larger hosts with more CPU/ RAM •  Use a container management framework that removes operational burden region Guest OS Bins/Libs Bins/ Libs App2App1 EC2 Instance Elastic Load Balancing Elastic Load Balancing API Gatewa y API Gatewa y
  • 26.
    Amazon EC2 ContainerService •  Supports Docker containers •  Runs on EC2 in your VPC •  Manages cluster resources •  Flexible scheduler built in or bring your own •  Integrates with ELB, EBS, IAM •  Amazon EC2 Container Registry
  • 27.
    Unaddressed Management Issues We’restill managing hosts •  OS Patches •  Host security •  Host resource management •  Scaling policy tweaks •  Redundancy/Resiliency/Failover
  • 28.
    « No Serveris Easier to Manage Than “No Server” » Werner Vogels, Amazon CTO
  • 29.
    •  Servers: •  Novisibility of underlying servers, storage and networking •  Operating System •  No need to select, configure, administer or patch the OS •  Capacity •  Elastic and (virtually) unlimited •  Availability •  Service is natively replicated and highly-available across multiple Availability Zones An Amazon definition of “Serverless”
  • 30.
    Continuous scaling No servers to manage Neverpay for idle – no cold servers (only happy accountants) Benefits of AWS Lambda
  • 31.
    AWS Lambda UseCases Run code without servers. Pay only for the compute time you consume. Be happy. Triggered by events or called from APIs: •  PUT to an Amazon S3 bucket •  Updates to Amazon DynamoDB table •  Invoked by an API Gateway endpoint •  Mobile app back-end call •  And many more… Makes it easy to: •  Perform real-time data processing •  Glue and choreograph systems •  Build scalable back-end services
  • 32.
    AWS Lambda: NoInfrastructure to Manage •  Run functions for up to 5 minutes •  Event-driven or scheduled •  Lambda handles: •  Capacity •  Scaling •  Deployment •  Monitoring •  Logging •  Web service front-end •  Security patching Region AWS Lambda Function AWS Lambda Function AWS Lambda Function AWS Lambda Function API Gateway
  • 33.
    Pay-per request •  Buycompute time in 100 ms increments for 21 microcents •  Request charge of 20 microcents •  No hourly, daily, or monthly minimums •  No per-device fees Free Tier 1 million requests and 400,000 GBs of compute every month, every customer Never pay for idle!
  • 34.
    Using AWS Lambda Bringyour own code •  Node.js, Java, Python •  Bring your own libraries (even native ones) Simple resource model •  Select power rating from 128 MB to 1.5 GB •  CPU and network allocated proportionately •  Reports actual usage Flexible authorization •  Securely grant access to resources, including VPCs •  Fine-grained control over who can call your functions Flexible use •  Call or send events •  Integrated with other AWS services •  Invoke from API Gateway
  • 35.
    Using AWS Lambda Programmingmodel •  AWS SDK built in (Python and Node.js) •  Eclipse plugin (Java) •  Lambda is the “webserver” •  Use processes, threads, / tmp, sockets normally Stateless •  Persist data using Amazon DynamoDB, S3, or ElastiCache •  No affinity to infrastructure (can’t “log in to the box”) Authoring functions •  Author directly using the console WYSIWYG editor •  Package code as a .zip and upload to Lambda or S3 •  Plugins for Eclipse and Visual Studio •  Command line tools Monitoring and logging •  Built-in metrics for requests, errors, latency, and throttles •  Built-in logs in Amazon CloudWatch Logs
  • 36.
    AWS Lambda Scaling • Lambda scales to match the event rate •  Don’t worry about over or under provisioning •  Pay only for what you use
  • 37.
  • 38.
    Benefits using anAPI Gateway Create a unified API front end for multiple microservices DDoS protection and throttling for back-end systems Authenticate and authorize requests Logging Analytics
  • 39.
    API Gateway asa front-end to APIs Internet Mobile Apps Websites Services API Gateway AWS Lambda functions Elastic Beanstalk Endpoints on Amazon EC2 On-Premises APIs EC2 Container Service Amazon CloudFront
  • 40.
    Web apps withAPI Gateway Dynamic content in AWS Lambda Data stored in Amazon DynamoDB API GatewayStatic content in Amazon S3 API Gateway
  • 41.
    Amazon Cognito API Gateway Lambda Lambda Lambda MOBILEDEVICE MOBILE BACKEND DATA AND CONTENT ANALYTICS NOTIFICATIONS S3 DynamoDB Mobile Analytics SNS Mobile Application with API Gateway
  • 42.
    λ λ λ API Gateway λ λ λλ Bucket Usage
 Table Media Metadata Table User Stat Table User
 Location Table λ λ λ Amazon Cognito
 Identity Broker Amazon Cognito
 Sync Store Amazon
 SNS Amazon
 Kinesis Media
 Bucket Log Table
  • 43.
  • 44.
    Microservice Architecture λλ λλ λλλλ λ λ API Gateway API Gateway
  • 45.
  • 46.
    Leveraging API Gateways forHybrid Architectures
  • 47.
    AWS Virtual PrivateNetwork (IPSec VPN)! Virtual Gateway Corporate data center Users Data center router Servers Internet IPSec VPN VPC Subnet Availability Zone Security Group VPC Subnet Availability Zone Security Group
  • 48.
    AWS Direct Connect! Virtual Gateway Corporate data center Users Data center router Servers VPC Subnet Availability Zone Security Group VPC Subnet Availability Zone Security Group Customer router AWS Direct Connect LocaBon AWS Direct Connect routers
  • 49.
    API Gateway asa front-end to cloud intranet apps! Intranet Apps API Gateway AWS Lambda functions Elastic Beanstalk Endpoints on Amazon EC2 EC2 Container Service Corporate Network
  • 50.
    AWS region! Private! connection! Your datacenter! Internet! In-house apps! API Gateway Cloud Apps! API Gateway API Gateway for hybrid workloads!
  • 51.
    AWS region! Private! connection! Your datacenter! Internet! API Gateway In-house apps! Cloud Apps! API Gateway API Gateway for hybrid workloads!
  • 52.
    AWS region! Private! connection! Your datacenter! Internet! API Gateway In-house apps! Cloud Apps! API Gateway API Gateway for hybrid workloads!
  • 53.
    AWS region! Private! connection! Your datacenter! Internet! API Gateway In-house apps! Cloud Apps! API Gateway API Gateway for hybrid workloads!
  • 54.
    Actions Lambda SNS SQS Serverless Services (DirectIntegration) S3 KinesisDDB Hybrid IoT Architecture RDS Redshift EC2 Rest of AWS EMR Machine Learning IoTThings Serverless IoT Service API Gateway
  • 55.
  • 56.
    Recap 1.  Current Trendsin IT 2.  The case for microservices 3.  Microservices on AWS 4.  Hybrid Architectures
  • 58.
    JP Le Goaller AWSSolutions Architecture jplg@amazon.com @jplegoal