SlideShare a Scribd company logo
AWS re:Invent
Operating Your Serverless API
at Scale
B o b K i n n e y — S e n i o r S D E
N o v e m b e r 2 9 , 2 0 1 7
What to expect from this session
Brief review of serverless (API Gateway/Lambda)
Customizing your API
Custom Timeouts
Gateway Responses
Monitoring Your API
Amazon CloudWatch Metrics/Alarms
Amazon CloudWatch Logs
Protecting Your API
Throttling
Authorization
Usage Plans
Updating Your API
Canary Release Deployments
No servers to provision
or manage
Scales with usage
Never pay for idle Availability and fault
tolerance built in
Serverless means…
Amazon API Gateway
Create a unified
API frontend for
multiple micro-
services
Authenticate and
authorize
requests to a
backend
DDoS protection
and throttling for
your backend
Throttle, meter,
and monetize API
usage by third-
party developers
API Gateway integrations
Internet
Mobile Apps
Websites
Services
AWS Lambda
functions
AWS
API Gateway
Cache
Endpoints on
Amazon EC2
All publicly
accessible
endpoints
Amazon
CloudWatch
Monitoring
Amazon
CloudFront
Any other
AWS service
API Gateway integrations
Internet
Mobile Apps
Websites
Services
AWS Lambda
functions
AWS
API Gateway
Cache
Endpoints on
Amazon EC2
All publicly
accessible
endpoints
Amazon
CloudWatch
Monitoring
Amazon
CloudFront
Any other
AWS service
NEW
Regional API Endpoints
AWS Lambda
Bring your own code
• Node.js, Java, Python,
C#
• 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
Flexible use
• Synchronous or
asynchronous
• Integrated with other
AWS services
Flexible authorization
• Securely grant access to
resources and VPCs
• Fine-grained control for
invoking your functions
Meet Doug
Doug loves coffee.
Doug also writes apps.
Doug built TAMPR—a service for
sharing reviews of coffee and coffee
shops.
Doug built the TAMPR backend
serverless, with API Gateway and
AWS Lambda.
External data sources
Doug built the first version of TAMPR
in part by aggregating data from other
sources. The service will fetch some
data on demand.
Unfortunately, the service is not as
reliable as he’d like, and sometimes
requests timeout after 30 seconds.
Doug would like to be able to fail faster
in these cases so his clients can retry.
Customizing Your API:
Custom Timeouts
Custom timeouts
AWS Lambda
• Set your maximum invocation time
• Set per function
API Gateway
• Set your integration timeout (1–29 s)
• Works with any integration type (HTTP/Lambda/AWS)
• Set per method
NEW
Check in with Doug
Doug now can configure his API to fail
fast and build retry logic in his
application for a more reliable
customer experience.
TAMPR website
Doug has already built native mobile
applications, but wants to add a
website with at least a subset of the
functionality before going live with
TAMPR.
He’s gotten CORS working in the
happy path, but a lot of his error
handling is failing due to lack of CORS
headers.
He needs a way to customize the error
responses coming from API Gateway
to add CORS headers.
Customizing Your API:
Gateway Responses
Gateway responses
Allows customization of various error responses
• Change HTTP status code
• Modify body content
• Add headers
Can customize specific responses and/or modify default
4XX/5XX
Demo
Check in with Doug
Doug now has a functional web app to
go along with his native mobile
applications and is ready to release his
app to the world.
First reviews of TAMPR
“I want to love this app, but every time
I try to check-in with my morning
coffee, I get errors.”
“The app works great if I’m getting an
afternoon coffee, but during the
mornings it’s almost unusable.”
“Too many errors, it never seems to
work.”
Monitoring Your API:
Amazon CloudWatch Metrics
Amazon CloudWatch Metrics
API Gateway Default metrics set
Count—total number of invokes received by API Gateway
4XXError—number of invokes that generated a 4XX error
(includes throttling)
5XXError—number of invokes that generated a 5XX error
Latency—total time API Gateway took to fully process request
IntegrationLatency—time API Gateway took to call integration
CacheHitCount—number of successful cache fetches
CacheMissCount—number of unsuccessful cache fetches
Amazon CloudWatch Metrics
Detailed metrics
Same set of metrics at method level
Can be enabled globally or only for specific methods
GET PUT DELETE
Amazon CloudWatch Metrics
Default Metrics
Included for free
Broken down by API stage
Detailed Metrics
Standard CloudWatch pricing
Broken down by method
Amazon CloudWatch Alarms
Any metric can be tied to an alarm
Alarm notifications can be sent to Amazon SNS topic
SNS topic can then send to any number of destinations
E-mail address
SQS queue
Lambda Function
Demo
Check in with Doug
Doug now has alarms to be alerted
when his customers get errors calling
his API, but how does he know why his
customers get errors?
Monitoring Your API:
Amazon CloudWatch Logs
Amazon CloudWatch Logs
API Gateway Logging
Two levels of logging, ERROR and INFO
Optionally log method request/body content
Set globally in stage, or override per method
API Gateway Access Logging
Customizable format for machine parsable
logs
Lambda Logging
Logging directly from your code
Basic request information included
Log Pivots
Build metrics based on log filters
Jump to logs that generated metrics
NEW
Demo
Check in with Doug
Thanks to logging, Doug now knows
that his API is generating errors during
peak loads because there’s spurious
traffic hitting a legacy API method at a
much higher than expected rate due to
a bug in a previous version of the app.
He now needs a way to to limit the
traffic from those devices to let other
traffic through from updated devices.
Protecting Your API:
Throttling
API Gateway throttling
Three levels of throttling for APIs
API Key level throttling—configurable in usage plan
Method level throttling—configurable in stage settings
Account level throttling—limits can be increased
API Gateway throttling
Token bucket algorithm
Burst—the maximum size of the bucket
Rate—the number of tokens added to the bucket
Demo
Check in with Doug
Thanks to throttling, Doug has limited
the impact from the buggy version of
the application by limiting the call rate
to the legacy method call.
Customers with the older version may
see some throttling errors, but users
who have upgraded to the latest
version are unaffected by the bad
actor.
TAMPR promotions
TAMPR has become popular and
coffee shops and roasters are
contacting Doug to discuss
possibilities of promotions through the
app.
Doug needs a way to allow these
shops to create accounts and create
and edit promotions on demand.
Protecting Your API:
Authentication/Authorization
Authentication type comparison
Feature AWS_IAM TOKEN REQUEST COGNITO
Authentication X X X X
Authorization X X X
Signature V4 X
Cognito User
Pools
X X X
Third-Party
Authentication
X X
Multiple
Header
Support
X
Additional
Costs
NONE Pay per
authorizer invoke
Pay per
authorizer invoke
NONE
NEW
Demo
Check in with Doug
TAMPR promotions have been a hit,
and the app is more popular than ever.
Doug is now speaking with other
services, such as a new site focused
on brunch spots, on how they can
work together.
Doug wants a way he can expose
portions of his API to these third
parties, but track their usage for
potential billing opportunities.
Protecting Your API:
Usage Plans
API Key Throttling
Rate/Burst per API Key
API Key Quota
Periodic limits per API Key
API Key Usage
Daily usage records
API Gateway usage plans
Check in with Doug TAMPR is continuing to grow and
some design decisions Doug made in
the early versions are causing scaling
issues.
Doug has rewritten and optimized a
large portion of the backend, but he’s
worried that despite automated tests
passing that there may be issues
switching 100% of the TAMPR traffic to
the new code.
He needs a way to test his new code
with a portion of his live traffic.
Managing Your API:
Canary Release Deployments
Canary release deployments
Tag a new deployment as a “canary” for a stage
Control the percentage of traffic the canary receives
Isolated metrics and logging
STAGE/canary
Any changes that can be tied to a deployment can be
tested
Including stage variables
NEW
Demo
Check in with Doug
TAMPR is continuing to grow and
Doug is now bringing in people to help
work on updates.
He is looking for ways to formalize the
update process.
Stages are named links to a deployed version of your API
Recommended for managing API lifecycle
Dev/test/prod
Alpha/beta/gamma
Support for parameterized values through stage variables
API stages
Run your APIs within your own DNS zone
Recommended for supporting multiple versions
api.tampr.com/v1 -> restapi1
api.tampr.com/v2 -> restapi2
Support for cross-region redundancy with regional API
endpoints
Custom domains
NEW
Portable API definition
JSON/YAML
Import/Export your API
API Gateway extensions
API definition as code
Swagger
AWS Serverless Application Model (SAM)
CloudFormation extension optimized for
serverless
New serverless resource types: functions, APIs,
and tables
Supports anything CloudFormation supports
Open specification (Apache 2.0)
https://github.com/awslabs/serverless-application-model
SAM template capabilities
• Can mix in other non-SAM CloudFormation
resources in the same template
• S3, Kinesis, Step Functions
• Supports use of Parameters, Mappings,
Outputs, others
• Supports Intrinsic Functions
• Can use ImportValue
(exceptions for RestApiId, Policies, StageName attributes)
• YAML or JSON
Other frameworks
Chalice
Fully managed build service that compiles source code,
runs tests, and produces software packages
Scales continuously and processes multiple builds
concurrently
You can provide custom build environments suited to
your needs with Docker images
Only pay by the minute for the compute resources you
use
Launched with CodePipeline and Jenkins integration
Can be used as a “Test” action in CodePipeline
AWS CodeBuild
Continuous delivery service for fast and
reliable application updates
Model and visualize your software release
process
Builds, tests, and deploys your code every time
there is a code change
Integrates with third-party tools and AWS
AWS CodePipeline
Be like Doug • Customize your API to meet your
operational needs
• Monitor your APIs with metrics and
alarms to find problems
• Use logging to diagnose problems with
your APIs
• Make use of throttling and
authentication to limit blast radius and
protect critical API components
• Make your API available to third parties
through usage plans
• Manage your API with the tools that
make your development/deployment
easier
aws.amazon.com/serverless
Other ways to connect
AWS Forums
forums.aws.amazon.com
StackOverflow
GitHub
github.com/aws
github.com/awslabs

More Related Content

What's hot

Enhanced Media Workflows Using Amazon AI
Enhanced Media Workflows Using Amazon AIEnhanced Media Workflows Using Amazon AI
Enhanced Media Workflows Using Amazon AI
Amazon Web Services
 
Modernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
Modernizing on EKS (Keynote)- AWS Container Day 2019 BarcelonaModernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
Modernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
Amazon Web Services
 
CON302_Building a CICD Pipeline for Containers on Amazon ECS
CON302_Building a CICD Pipeline for Containers on Amazon ECSCON302_Building a CICD Pipeline for Containers on Amazon ECS
CON302_Building a CICD Pipeline for Containers on Amazon ECS
Amazon Web Services
 
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and BeyondGPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
Amazon Web Services
 
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
Amazon Web Services
 
Advanced Serverless Apps With Step Functions
Advanced Serverless Apps With Step FunctionsAdvanced Serverless Apps With Step Functions
Advanced Serverless Apps With Step Functions
Amazon Web Services
 
AWS DeepLens Workshop: Building Computer Vision Applications
AWS DeepLens Workshop: Building Computer Vision ApplicationsAWS DeepLens Workshop: Building Computer Vision Applications
AWS DeepLens Workshop: Building Computer Vision Applications
Amazon Web Services
 
Migrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWSMigrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWS
Amazon Web Services
 
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Amazon Web Services
 
規劃大規模遷移到 AWS 的最佳實踐
規劃大規模遷移到 AWS 的最佳實踐規劃大規模遷移到 AWS 的最佳實踐
規劃大規模遷移到 AWS 的最佳實踐
Amazon Web Services
 
Keynote 2: AWS re:Invent 2017 Recap - Solutions Updates
Keynote 2: AWS re:Invent 2017 Recap - Solutions UpdatesKeynote 2: AWS re:Invent 2017 Recap - Solutions Updates
Keynote 2: AWS re:Invent 2017 Recap - Solutions Updates
Amazon Web Services
 
Forza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessForza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni Serverless
Amazon Web Services
 
WIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS ServicesWIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS Services
Amazon Web Services
 
Introducing Amazon EKS
Introducing Amazon EKSIntroducing Amazon EKS
Introducing Amazon EKS
Amazon Web Services
 
IOT326_Developing Predictive Applications Using
IOT326_Developing Predictive Applications UsingIOT326_Developing Predictive Applications Using
IOT326_Developing Predictive Applications Using
Amazon Web Services
 
AWS Summit Singapore - More Containers, Less Operations
AWS Summit Singapore - More Containers, Less OperationsAWS Summit Singapore - More Containers, Less Operations
AWS Summit Singapore - More Containers, Less Operations
Amazon Web Services
 
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdfDEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
Amazon Web Services
 
Building Serverless Microservices with AWS
Building Serverless Microservices with AWSBuilding Serverless Microservices with AWS
Building Serverless Microservices with AWS
Donnie Prakoso
 
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
Amazon Web Services
 
Breaking the Monolith Road to Containers
Breaking the Monolith Road to ContainersBreaking the Monolith Road to Containers
Breaking the Monolith Road to Containers
Amazon Web Services
 

What's hot (20)

Enhanced Media Workflows Using Amazon AI
Enhanced Media Workflows Using Amazon AIEnhanced Media Workflows Using Amazon AI
Enhanced Media Workflows Using Amazon AI
 
Modernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
Modernizing on EKS (Keynote)- AWS Container Day 2019 BarcelonaModernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
Modernizing on EKS (Keynote)- AWS Container Day 2019 Barcelona
 
CON302_Building a CICD Pipeline for Containers on Amazon ECS
CON302_Building a CICD Pipeline for Containers on Amazon ECSCON302_Building a CICD Pipeline for Containers on Amazon ECS
CON302_Building a CICD Pipeline for Containers on Amazon ECS
 
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and BeyondGPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
GPSTEC317-From Leaves to Lawns AWS Greengrass at the Edge and Beyond
 
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
Authoring and Deploying Serverless Applications with AWS SAM - SRV311 - re:In...
 
Advanced Serverless Apps With Step Functions
Advanced Serverless Apps With Step FunctionsAdvanced Serverless Apps With Step Functions
Advanced Serverless Apps With Step Functions
 
AWS DeepLens Workshop: Building Computer Vision Applications
AWS DeepLens Workshop: Building Computer Vision ApplicationsAWS DeepLens Workshop: Building Computer Vision Applications
AWS DeepLens Workshop: Building Computer Vision Applications
 
Migrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWSMigrating Microsoft Workloads to AWS
Migrating Microsoft Workloads to AWS
 
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
Monitoring and Troubleshooting in a Serverless World - SRV303 - re:Invent 2017
 
規劃大規模遷移到 AWS 的最佳實踐
規劃大規模遷移到 AWS 的最佳實踐規劃大規模遷移到 AWS 的最佳實踐
規劃大規模遷移到 AWS 的最佳實踐
 
Keynote 2: AWS re:Invent 2017 Recap - Solutions Updates
Keynote 2: AWS re:Invent 2017 Recap - Solutions UpdatesKeynote 2: AWS re:Invent 2017 Recap - Solutions Updates
Keynote 2: AWS re:Invent 2017 Recap - Solutions Updates
 
Forza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni ServerlessForza Computazionale e Applicazioni Serverless
Forza Computazionale e Applicazioni Serverless
 
WIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS ServicesWIN205-Building a Better .NET Bot with AWS Services
WIN205-Building a Better .NET Bot with AWS Services
 
Introducing Amazon EKS
Introducing Amazon EKSIntroducing Amazon EKS
Introducing Amazon EKS
 
IOT326_Developing Predictive Applications Using
IOT326_Developing Predictive Applications UsingIOT326_Developing Predictive Applications Using
IOT326_Developing Predictive Applications Using
 
AWS Summit Singapore - More Containers, Less Operations
AWS Summit Singapore - More Containers, Less OperationsAWS Summit Singapore - More Containers, Less Operations
AWS Summit Singapore - More Containers, Less Operations
 
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdfDEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
DEV305_Manage Your Applications with AWS Elastic Beanstalk.pdf
 
Building Serverless Microservices with AWS
Building Serverless Microservices with AWSBuilding Serverless Microservices with AWS
Building Serverless Microservices with AWS
 
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
MSC202_Learn How Salesforce Used ADCs for App Load Balancing for an Internati...
 
Breaking the Monolith Road to Containers
Breaking the Monolith Road to ContainersBreaking the Monolith Road to Containers
Breaking the Monolith Road to Containers
 

Similar to SRV307_Operating Your Serverless API at Scale

AWS re:Invent 2016: Operating Your Production API (SVR402)
AWS re:Invent 2016: Operating Your Production API (SVR402)AWS re:Invent 2016: Operating Your Production API (SVR402)
AWS re:Invent 2016: Operating Your Production API (SVR402)
Amazon Web Services
 
Operating Your Production API
Operating Your Production APIOperating Your Production API
Operating Your Production API
Amazon Web Services
 
Operating your Production API
Operating your Production APIOperating your Production API
Operating your Production API
Amazon Web Services
 
Deep Dive on Serverless Stack
Deep Dive on Serverless StackDeep Dive on Serverless Stack
Deep Dive on Serverless Stack
Amazon Web Services
 
The ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.ioThe ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.io
Blendr.io
 
Serverless-AWS SAM CLI Session: Developer Meet Up
Serverless-AWS SAM CLI Session: Developer Meet UpServerless-AWS SAM CLI Session: Developer Meet Up
Serverless-AWS SAM CLI Session: Developer Meet Up
Amazon Web Services
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
Amazon Web Services
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Amazon Web Services
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
Amazon Web Services
 
以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端
Amazon Web Services
 
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar SeriesContinuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Amazon Web Services
 
ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017
Amazon Web Services
 
Introduction to Serverless on AWS
Introduction to Serverless on AWSIntroduction to Serverless on AWS
Introduction to Serverless on AWS
Amazon Web Services
 
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Amazon Web Services
 
Deep Dive on Serverless Application Development NY Loft
Deep Dive on Serverless Application Development NY LoftDeep Dive on Serverless Application Development NY Loft
Deep Dive on Serverless Application Development NY Loft
Amazon Web Services
 
Operating Your Serverless API in Production at Scale - AWS Online Tech Talks
Operating Your Serverless API in Production at Scale - AWS Online Tech TalksOperating Your Serverless API in Production at Scale - AWS Online Tech Talks
Operating Your Serverless API in Production at Scale - AWS Online Tech Talks
Amazon Web Services
 
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
Amazon Web Services
 
Ci/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO ClubCi/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO Club
Boaz Ziniman
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
Mark Bate
 
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
Amazon Web Services
 

Similar to SRV307_Operating Your Serverless API at Scale (20)

AWS re:Invent 2016: Operating Your Production API (SVR402)
AWS re:Invent 2016: Operating Your Production API (SVR402)AWS re:Invent 2016: Operating Your Production API (SVR402)
AWS re:Invent 2016: Operating Your Production API (SVR402)
 
Operating Your Production API
Operating Your Production APIOperating Your Production API
Operating Your Production API
 
Operating your Production API
Operating your Production APIOperating your Production API
Operating your Production API
 
Deep Dive on Serverless Stack
Deep Dive on Serverless StackDeep Dive on Serverless Stack
Deep Dive on Serverless Stack
 
The ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.ioThe ultimate api checklist by Blendr.io
The ultimate api checklist by Blendr.io
 
Serverless-AWS SAM CLI Session: Developer Meet Up
Serverless-AWS SAM CLI Session: Developer Meet UpServerless-AWS SAM CLI Session: Developer Meet Up
Serverless-AWS SAM CLI Session: Developer Meet Up
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
 
Managing the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS LambdaManaging the Continuous Delivery of Code to AWS Lambda
Managing the Continuous Delivery of Code to AWS Lambda
 
以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端
 
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar SeriesContinuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
Continuous Delivery with AWS Lambda - AWS April 2016 Webinar Series
 
ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017ANZ Dev Lounge Session - Feb 2017
ANZ Dev Lounge Session - Feb 2017
 
Introduction to Serverless on AWS
Introduction to Serverless on AWSIntroduction to Serverless on AWS
Introduction to Serverless on AWS
 
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
Zombie Apocalypse Workshop by Warren Santer and Kyle Somers, Solutions Archit...
 
Deep Dive on Serverless Application Development NY Loft
Deep Dive on Serverless Application Development NY LoftDeep Dive on Serverless Application Development NY Loft
Deep Dive on Serverless Application Development NY Loft
 
Operating Your Serverless API in Production at Scale - AWS Online Tech Talks
Operating Your Serverless API in Production at Scale - AWS Online Tech TalksOperating Your Serverless API in Production at Scale - AWS Online Tech Talks
Operating Your Serverless API in Production at Scale - AWS Online Tech Talks
 
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
AWS August Webinar Series - Building Serverless Backends with AWS Lambda and ...
 
Ci/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO ClubCi/CD for AWS Lambda Projects - JLM CTO Club
Ci/CD for AWS Lambda Projects - JLM CTO Club
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
Operating Your Serverless API in Production at Scale - SRV217 - Chicago AWS S...
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
Amazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Amazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
Amazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Amazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
Amazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
Amazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
Amazon Web Services
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
Amazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

SRV307_Operating Your Serverless API at Scale

  • 1. AWS re:Invent Operating Your Serverless API at Scale B o b K i n n e y — S e n i o r S D E N o v e m b e r 2 9 , 2 0 1 7
  • 2. What to expect from this session Brief review of serverless (API Gateway/Lambda) Customizing your API Custom Timeouts Gateway Responses Monitoring Your API Amazon CloudWatch Metrics/Alarms Amazon CloudWatch Logs Protecting Your API Throttling Authorization Usage Plans Updating Your API Canary Release Deployments
  • 3. No servers to provision or manage Scales with usage Never pay for idle Availability and fault tolerance built in Serverless means…
  • 4. Amazon API Gateway Create a unified API frontend for multiple micro- services Authenticate and authorize requests to a backend DDoS protection and throttling for your backend Throttle, meter, and monetize API usage by third- party developers
  • 5. API Gateway integrations Internet Mobile Apps Websites Services AWS Lambda functions AWS API Gateway Cache Endpoints on Amazon EC2 All publicly accessible endpoints Amazon CloudWatch Monitoring Amazon CloudFront Any other AWS service
  • 6. API Gateway integrations Internet Mobile Apps Websites Services AWS Lambda functions AWS API Gateway Cache Endpoints on Amazon EC2 All publicly accessible endpoints Amazon CloudWatch Monitoring Amazon CloudFront Any other AWS service NEW Regional API Endpoints
  • 7. AWS Lambda Bring your own code • Node.js, Java, Python, C# • 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 Flexible use • Synchronous or asynchronous • Integrated with other AWS services Flexible authorization • Securely grant access to resources and VPCs • Fine-grained control for invoking your functions
  • 8. Meet Doug Doug loves coffee. Doug also writes apps. Doug built TAMPR—a service for sharing reviews of coffee and coffee shops. Doug built the TAMPR backend serverless, with API Gateway and AWS Lambda.
  • 9. External data sources Doug built the first version of TAMPR in part by aggregating data from other sources. The service will fetch some data on demand. Unfortunately, the service is not as reliable as he’d like, and sometimes requests timeout after 30 seconds. Doug would like to be able to fail faster in these cases so his clients can retry.
  • 11. Custom timeouts AWS Lambda • Set your maximum invocation time • Set per function API Gateway • Set your integration timeout (1–29 s) • Works with any integration type (HTTP/Lambda/AWS) • Set per method NEW
  • 12. Check in with Doug Doug now can configure his API to fail fast and build retry logic in his application for a more reliable customer experience.
  • 13. TAMPR website Doug has already built native mobile applications, but wants to add a website with at least a subset of the functionality before going live with TAMPR. He’s gotten CORS working in the happy path, but a lot of his error handling is failing due to lack of CORS headers. He needs a way to customize the error responses coming from API Gateway to add CORS headers.
  • 15. Gateway responses Allows customization of various error responses • Change HTTP status code • Modify body content • Add headers Can customize specific responses and/or modify default 4XX/5XX
  • 16. Demo
  • 17. Check in with Doug Doug now has a functional web app to go along with his native mobile applications and is ready to release his app to the world.
  • 18. First reviews of TAMPR “I want to love this app, but every time I try to check-in with my morning coffee, I get errors.” “The app works great if I’m getting an afternoon coffee, but during the mornings it’s almost unusable.” “Too many errors, it never seems to work.”
  • 19. Monitoring Your API: Amazon CloudWatch Metrics
  • 20. Amazon CloudWatch Metrics API Gateway Default metrics set Count—total number of invokes received by API Gateway 4XXError—number of invokes that generated a 4XX error (includes throttling) 5XXError—number of invokes that generated a 5XX error Latency—total time API Gateway took to fully process request IntegrationLatency—time API Gateway took to call integration CacheHitCount—number of successful cache fetches CacheMissCount—number of unsuccessful cache fetches
  • 21. Amazon CloudWatch Metrics Detailed metrics Same set of metrics at method level Can be enabled globally or only for specific methods GET PUT DELETE
  • 22. Amazon CloudWatch Metrics Default Metrics Included for free Broken down by API stage Detailed Metrics Standard CloudWatch pricing Broken down by method
  • 23. Amazon CloudWatch Alarms Any metric can be tied to an alarm Alarm notifications can be sent to Amazon SNS topic SNS topic can then send to any number of destinations E-mail address SQS queue Lambda Function
  • 24. Demo
  • 25. Check in with Doug Doug now has alarms to be alerted when his customers get errors calling his API, but how does he know why his customers get errors?
  • 26. Monitoring Your API: Amazon CloudWatch Logs
  • 27. Amazon CloudWatch Logs API Gateway Logging Two levels of logging, ERROR and INFO Optionally log method request/body content Set globally in stage, or override per method API Gateway Access Logging Customizable format for machine parsable logs Lambda Logging Logging directly from your code Basic request information included Log Pivots Build metrics based on log filters Jump to logs that generated metrics NEW
  • 28. Demo
  • 29. Check in with Doug Thanks to logging, Doug now knows that his API is generating errors during peak loads because there’s spurious traffic hitting a legacy API method at a much higher than expected rate due to a bug in a previous version of the app. He now needs a way to to limit the traffic from those devices to let other traffic through from updated devices.
  • 31. API Gateway throttling Three levels of throttling for APIs API Key level throttling—configurable in usage plan Method level throttling—configurable in stage settings Account level throttling—limits can be increased
  • 32. API Gateway throttling Token bucket algorithm Burst—the maximum size of the bucket Rate—the number of tokens added to the bucket
  • 33. Demo
  • 34. Check in with Doug Thanks to throttling, Doug has limited the impact from the buggy version of the application by limiting the call rate to the legacy method call. Customers with the older version may see some throttling errors, but users who have upgraded to the latest version are unaffected by the bad actor.
  • 35. TAMPR promotions TAMPR has become popular and coffee shops and roasters are contacting Doug to discuss possibilities of promotions through the app. Doug needs a way to allow these shops to create accounts and create and edit promotions on demand.
  • 37. Authentication type comparison Feature AWS_IAM TOKEN REQUEST COGNITO Authentication X X X X Authorization X X X Signature V4 X Cognito User Pools X X X Third-Party Authentication X X Multiple Header Support X Additional Costs NONE Pay per authorizer invoke Pay per authorizer invoke NONE NEW
  • 38. Demo
  • 39. Check in with Doug TAMPR promotions have been a hit, and the app is more popular than ever. Doug is now speaking with other services, such as a new site focused on brunch spots, on how they can work together. Doug wants a way he can expose portions of his API to these third parties, but track their usage for potential billing opportunities.
  • 41. API Key Throttling Rate/Burst per API Key API Key Quota Periodic limits per API Key API Key Usage Daily usage records API Gateway usage plans
  • 42. Check in with Doug TAMPR is continuing to grow and some design decisions Doug made in the early versions are causing scaling issues. Doug has rewritten and optimized a large portion of the backend, but he’s worried that despite automated tests passing that there may be issues switching 100% of the TAMPR traffic to the new code. He needs a way to test his new code with a portion of his live traffic.
  • 43. Managing Your API: Canary Release Deployments
  • 44. Canary release deployments Tag a new deployment as a “canary” for a stage Control the percentage of traffic the canary receives Isolated metrics and logging STAGE/canary Any changes that can be tied to a deployment can be tested Including stage variables NEW
  • 45. Demo
  • 46. Check in with Doug TAMPR is continuing to grow and Doug is now bringing in people to help work on updates. He is looking for ways to formalize the update process.
  • 47. Stages are named links to a deployed version of your API Recommended for managing API lifecycle Dev/test/prod Alpha/beta/gamma Support for parameterized values through stage variables API stages
  • 48. Run your APIs within your own DNS zone Recommended for supporting multiple versions api.tampr.com/v1 -> restapi1 api.tampr.com/v2 -> restapi2 Support for cross-region redundancy with regional API endpoints Custom domains NEW
  • 49. Portable API definition JSON/YAML Import/Export your API API Gateway extensions API definition as code Swagger
  • 50. AWS Serverless Application Model (SAM) CloudFormation extension optimized for serverless New serverless resource types: functions, APIs, and tables Supports anything CloudFormation supports Open specification (Apache 2.0) https://github.com/awslabs/serverless-application-model
  • 51. SAM template capabilities • Can mix in other non-SAM CloudFormation resources in the same template • S3, Kinesis, Step Functions • Supports use of Parameters, Mappings, Outputs, others • Supports Intrinsic Functions • Can use ImportValue (exceptions for RestApiId, Policies, StageName attributes) • YAML or JSON
  • 53. Fully managed build service that compiles source code, runs tests, and produces software packages Scales continuously and processes multiple builds concurrently You can provide custom build environments suited to your needs with Docker images Only pay by the minute for the compute resources you use Launched with CodePipeline and Jenkins integration Can be used as a “Test” action in CodePipeline AWS CodeBuild
  • 54. Continuous delivery service for fast and reliable application updates Model and visualize your software release process Builds, tests, and deploys your code every time there is a code change Integrates with third-party tools and AWS AWS CodePipeline
  • 55. Be like Doug • Customize your API to meet your operational needs • Monitor your APIs with metrics and alarms to find problems • Use logging to diagnose problems with your APIs • Make use of throttling and authentication to limit blast radius and protect critical API components • Make your API available to third parties through usage plans • Manage your API with the tools that make your development/deployment easier
  • 57. Other ways to connect AWS Forums forums.aws.amazon.com StackOverflow GitHub github.com/aws github.com/awslabs