SlideShare a Scribd company logo
in production
an experience reportan experience report
what you should know before you go to production
ServerlessServerless
Yan Cui
http://theburningmonk.com
@theburningmonk
Serverless in Production, an experience report (cloudXchange)
apr, 2016
Serverless in Production, an experience report (cloudXchange)
hey guys, vote on this post
and I’ll announce a winner at
10PM tonight
10PM
traffic
10PM
traffic
70-100x
low utilisation to leave room for spikes
EC2 scaling is slow, so scale earlier
lots of $$$ for unused resources
up to 30 mins for deployment
deployment required downtime
be small
be fast
have zero downtime
have no lock-step
DEPLOYMENTS SHOULD...
FEATURES SHOULD...
be deployable independently
be loosely-coupled
WE WANT TO...
minimise cost for unused resources
minimise ops effort
reduce tech mess
deliver visible improvements faster
nov, 2016
170 Lambda functions in prod
1.2 GB deployment packages in prod
95% cost saving vs EC2
15x no. of prod releases per month
time
is a good fit
1st function in prod!
time
is a good fit
?
time
is a good fit
1st function in prod!
ALERTING
CI / CD
TESTING
LOGGING
MONITORING
170 functions
? ?
time
is a good fit
1st function in prod!
SECURITY
DISTRIBUTED TRACING
CONFIG MANAGEMENT
evolving the PLATFORM
rebuilt search
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearch
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Rebuilt
with Lambda
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
getting PRODUCTION READY
choose a tried-and-tested
deployment framework,
don’t invent your own
http://serverless.com
https://github.com/awslabs/serverless-application-model
TESTING
amzn.to/29Lxuzu
Level of Testing
1.Unit
do our objects do the right thing?
are they easy to work with?
Serverless in Production, an experience report (cloudXchange)
Level of Testing
1.Unit
2.Integration
does our code work against code we
can’t change?
handler
handler
test by invoking
the handler
Level of Testing
1.Unit
2.Integration
3.Acceptance
does the whole system work?
Level of Testing
unit
integration
acceptance
feedback
confidence
“…We find that tests that mock external
libraries often need to be complex to
get the code into the right state for the
functionality we need to exercise.
The mess in such tests is telling us that
the design isn’t right but, instead of
fixing the problem by improving the
code, we have to carry the extra
complexity in both code and test…”
Don’t Mock Types You Can’t Change
“…The second risk is that we have to be
sure that the behaviour we stub or mock
matches what the external library will
actually do…
Even if we get it right once, we have to
make sure that the tests remain valid
when we upgrade the libraries…”
Don’t Mock Types You Can’t Change
Don’t Mock Types You Can’t Change
Services
Paul Johnston
The serverless approach to
testing is different and may
actually be easier.
http://bit.ly/2t5viwK
LambdaAPI Gateway DynamoDB
LambdaAPI Gateway DynamoDB
Unit Tests
LambdaAPI Gateway DynamoDB
Unit Tests
Mock/Stub
is our request correct?
is the request mapping
set up correctly?is the API resources
configured correctly?
are we assuming the
correct schema?
LambdaAPI Gateway DynamoDB
is Lambda proxy
configured correctly?
is IAM policy set
up correctly?
is the table created?
what unit tests will not tell you…
Serverless in Production, an experience report (cloudXchange)
most Lambda functions are simple
have single purpose, the risk of
shipping broken software has largely
shifted to how they integrate with
external services
observation
Serverless in Production, an experience report (cloudXchange)
optimize towards shipping working
software, even if it means slowing
down your feedback loop…
“…Wherever possible, an acceptance
test should exercise the system end-to-
end without directly calling its internal
code.
An end-to-end test interacts with the
system only from the outside: through
its interface…”
Testing End-to-End
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Test Input
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Test Input
Validate
integration tests exercise
system’s Integration with its
external dependencies
my code
acceptance tests exercise
system End-to-End from
the outside
my code
integration tests differ from
acceptance tests only in HOW the
Lambda functions are invoked
observation
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
CI + CD PIPELINE
me
deployment scripts that only
live on the CI box is a disaster
waiting to happen…
Jenkins build config deploys and tests
unit + integration tests
deploy
acceptance tests
if [ "$1" = "deploy" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE 'node_modules/.bin/sls' deploy -s $STAGE -r $REGION
elif [ "$1" = "int-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run int-$STAGE
elif [ "$1" = "acceptance-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run acceptance-$STAGE
else
usage
exit 1
fi
if [ "$1" = "deploy" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE 'node_modules/.bin/sls' deploy -s $STAGE -r $REGION
elif [ "$1" = "int-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run int-$STAGE
elif [ "$1" = "acceptance-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run acceptance-$STAGE
else
usage
exit 1
fi
install Serverless framework
as dev dependency
if [ "$1" = "deploy" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE 'node_modules/.bin/sls' deploy -s $STAGE -r $REGION
elif [ "$1" = "int-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run int-$STAGE
elif [ "$1" = "acceptance-test" ] && [ $# -eq 4 ]; then
STAGE=$2
REGION=$3
PROFILE=$4
npm install
AWS_PROFILE=$PROFILE npm run acceptance-$STAGE
else
usage
exit 1
fi
install Serverless framework
as dev dependency
mitigate version conflicts
build.sh allows repeatable builds on both local & CI
Serverless in Production, an experience report (cloudXchange)
Auto Auto Manual
Serverless in Production, an experience report (cloudXchange)
LOGGING
Serverless in Production, an experience report (cloudXchange)
2016-07-12T12:24:37.571Z 994f18f9-482b-11e6-8668-53e4eab441ae
GOT is off air, what do I do now?
2016-07-12T12:24:37.571Z 994f18f9-482b-11e6-8668-53e4eab441ae
GOT is off air, what do I do now?
UTC Timestamp API Gateway Request Id
your log message
me
Logs are not easily searchable
in CloudWatch Logs.
CloudWatch Logs
CloudWatch Logs AWS Lambda ELK stack
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
DISTRIBUTED TRACING
Serverless in Production, an experience report (cloudXchange)
a user
my followers didn’t receive
my new post!
where could the
problem be?
correlation IDs*
* eg. request-id, user-id, yubl-id, etc.
wrap HTTP client & AWS SDK clients
to forward captured correlation IDs
kinesis client
http client
sns client
Amazon X-Ray
Amazon X-Ray
X-Ray traces do not span over API
Gateway, or async event sources
MONITORING + ALERTING
no place to install agents/daemons
• invocation Count
• error Count
• latency
• throttling
• granular to the minute
• support custom metrics
Serverless in Production, an experience report (cloudXchange)
my code
my code
my code
internet internet
press button something happens
console.log(“hydrating yubls from db…”);
console.log(“fetching user info from user-api”);
console.log(“MONITORING|1489795335|27.4|latency|user-api-latency”);
console.log(“MONITORING|1489795335|8|count|yubls-served”);
timestamp metric value
metric type
metric namemetrics
logs
CloudWatch Logs AWS Lambda
ELK stack
logs
metrics
CloudWatch
don’t forget to setup dashboards
& CW alarms
CONFIG MANAGEMENT
sensitive data should be encrypted
in-flight, and at-rest
enforce role-based access to
sensitive configuration values
SSM Parameter Store
HTTPS
role-based access
encrypted in-flight
SSM Parameter Store
encrypt
role-based access
SSM Parameter Store
encrypted at-rest
HTTPS
role-based access
SSM Parameter Store
encrypted in-flight
API Gateway and Kinesis
Authentication & authorisation (IAM, Cognito)
Testing
Running & Debugging functions locally
Log aggregation
Monitoring & Alerting
X-Ray
Correlation IDs
CI/CD
Performance and Cost optimisation
Error Handling
Configuration management
VPC
Security
Leading practices (API Gateway, Kinesis, Lambda)
Canary deployments
http://bit.ly/production-ready-serverless
get 40% off
with: ytcui
@theburningmonk
theburningmonk.com
github.com/theburningmonk

More Related Content

What's hot (19)

PDF
Build reactive systems on lambda
Yan Cui
 
PDF
Serverless in production, an experience report (microservices london)
Yan Cui
 
PDF
DevOps with Serverless
Yan Cui
 
PDF
Security in serverless world
Yan Cui
 
PDF
Serverless in production, an experience report (London js community)
Yan Cui
 
PDF
Serverless in production, an experience report (codemotion milan)
Yan Cui
 
PDF
The future of paas is serverless
Yan Cui
 
PPTX
A. De Biase/C. Quatrini/M. Barsocchi - API Release Process: how to make peopl...
Codemotion
 
PDF
Serverless in production, an experience report (BuildStuff)
Yan Cui
 
PDF
Using PHP Functions! (Not those functions, Google Cloud Functions)
Chris Tankersley
 
PPTX
You are not_hiding_from_me_.net
Chung Wee Jing
 
PDF
Serverless in production, an experience report (IWOMM)
Yan Cui
 
PDF
Automate Thyself
Ortus Solutions, Corp
 
PDF
Serverless in production, an experience report (NDC London 2018)
Yan Cui
 
PDF
Securing Legacy CFML Code
ColdFusionConference
 
PDF
Karate, the black belt of HTTP API testing?
Bertrand Delacretaz
 
PDF
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
PPTX
Agility Requires Safety
Yevgeniy Brikman
 
PDF
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Joe Ferguson
 
Build reactive systems on lambda
Yan Cui
 
Serverless in production, an experience report (microservices london)
Yan Cui
 
DevOps with Serverless
Yan Cui
 
Security in serverless world
Yan Cui
 
Serverless in production, an experience report (London js community)
Yan Cui
 
Serverless in production, an experience report (codemotion milan)
Yan Cui
 
The future of paas is serverless
Yan Cui
 
A. De Biase/C. Quatrini/M. Barsocchi - API Release Process: how to make peopl...
Codemotion
 
Serverless in production, an experience report (BuildStuff)
Yan Cui
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Chris Tankersley
 
You are not_hiding_from_me_.net
Chung Wee Jing
 
Serverless in production, an experience report (IWOMM)
Yan Cui
 
Automate Thyself
Ortus Solutions, Corp
 
Serverless in production, an experience report (NDC London 2018)
Yan Cui
 
Securing Legacy CFML Code
ColdFusionConference
 
Karate, the black belt of HTTP API testing?
Bertrand Delacretaz
 
Laravel Forge: Hello World to Hello Production
Joe Ferguson
 
Agility Requires Safety
Yevgeniy Brikman
 
php[world] 2015 Laravel 5.1: From Homestead to the Cloud
Joe Ferguson
 

Similar to Serverless in Production, an experience report (cloudXchange) (17)

PDF
Serverless in production, an experience report (London DevOps)
Yan Cui
 
PDF
Serverless in production, an experience report (JeffConf)
Yan Cui
 
PDF
Serverless in production, an experience report
Yan Cui
 
PDF
AWS Lambda from the trenches
Yan Cui
 
PDF
AWS Lambda from the trenches (Serverless London)
Yan Cui
 
PDF
Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Codemotion
 
PDF
Serverless in production (O'Reilly Software Architecture)
Yan Cui
 
PDF
Serverless in production, an experience report (NDC London, 31 Jan 2018)
Domas Lasauskas
 
PDF
AWS Lambda from the Trenches
Yan Cui
 
ODP
AutoScaling and Drupal
Promet Source
 
PPTX
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin
 
PPTX
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Docker, Inc.
 
PDF
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
PPTX
Security Testing with Zap
Soluto
 
PDF
APIdays Barcelona 2019 - How to build a social network on Serverless with Yan...
apidays
 
PDF
How to build a social network on serverless
Yan Cui
 
PPTX
All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv...
DevOpsDays Tel Aviv
 
Serverless in production, an experience report (London DevOps)
Yan Cui
 
Serverless in production, an experience report (JeffConf)
Yan Cui
 
Serverless in production, an experience report
Yan Cui
 
AWS Lambda from the trenches
Yan Cui
 
AWS Lambda from the trenches (Serverless London)
Yan Cui
 
Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Codemotion
 
Serverless in production (O'Reilly Software Architecture)
Yan Cui
 
Serverless in production, an experience report (NDC London, 31 Jan 2018)
Domas Lasauskas
 
AWS Lambda from the Trenches
Yan Cui
 
AutoScaling and Drupal
Promet Source
 
Useful practices of creation automatic tests by using cucumber jvm
Anton Shapin
 
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Docker, Inc.
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
Security Testing with Zap
Soluto
 
APIdays Barcelona 2019 - How to build a social network on Serverless with Yan...
apidays
 
How to build a social network on serverless
Yan Cui
 
All you need is Zap - Omer Levi Hevroni & Yshay Yaacobi - DevOpsDays Tel Aviv...
DevOpsDays Tel Aviv
 

More from Yan Cui (20)

PDF
How to win the game of trade-offs
Yan Cui
 
PDF
How to choose the right messaging service
Yan Cui
 
PDF
How to choose the right messaging service for your workload
Yan Cui
 
PDF
Patterns and practices for building resilient serverless applications.pdf
Yan Cui
 
PDF
Lambda and DynamoDB best practices
Yan Cui
 
PDF
Lessons from running AppSync in prod
Yan Cui
 
PDF
Serverless observability - a hero's perspective
Yan Cui
 
PDF
How to ship customer value faster with step functions
Yan Cui
 
PDF
How serverless changes the cost paradigm
Yan Cui
 
PDF
Why your next serverless project should use AWS AppSync
Yan Cui
 
PDF
Build social network in 4 weeks
Yan Cui
 
PDF
Patterns and practices for building resilient serverless applications
Yan Cui
 
PDF
How to bring chaos engineering to serverless
Yan Cui
 
PDF
Migrating existing monolith to serverless in 8 steps
Yan Cui
 
PDF
Building a social network in under 4 weeks with Serverless and GraphQL
Yan Cui
 
PDF
FinDev as a business advantage in the post covid19 economy
Yan Cui
 
PDF
How to improve lambda cold starts
Yan Cui
 
PDF
What can you do with lambda in 2020
Yan Cui
 
PDF
A chaos experiment a day, keeping the outage away
Yan Cui
 
PDF
How to debug slow lambda response times
Yan Cui
 
How to win the game of trade-offs
Yan Cui
 
How to choose the right messaging service
Yan Cui
 
How to choose the right messaging service for your workload
Yan Cui
 
Patterns and practices for building resilient serverless applications.pdf
Yan Cui
 
Lambda and DynamoDB best practices
Yan Cui
 
Lessons from running AppSync in prod
Yan Cui
 
Serverless observability - a hero's perspective
Yan Cui
 
How to ship customer value faster with step functions
Yan Cui
 
How serverless changes the cost paradigm
Yan Cui
 
Why your next serverless project should use AWS AppSync
Yan Cui
 
Build social network in 4 weeks
Yan Cui
 
Patterns and practices for building resilient serverless applications
Yan Cui
 
How to bring chaos engineering to serverless
Yan Cui
 
Migrating existing monolith to serverless in 8 steps
Yan Cui
 
Building a social network in under 4 weeks with Serverless and GraphQL
Yan Cui
 
FinDev as a business advantage in the post covid19 economy
Yan Cui
 
How to improve lambda cold starts
Yan Cui
 
What can you do with lambda in 2020
Yan Cui
 
A chaos experiment a day, keeping the outage away
Yan Cui
 
How to debug slow lambda response times
Yan Cui
 

Recently uploaded (20)

PPTX
Essential Content-centric Plugins for your Website
Laura Byrne
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PDF
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
Edge AI and Vision Alliance
 
PDF
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
PPTX
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PPTX
Digital Circuits, important subject in CS
contactparinay1
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
Home Cleaning App Development Services.pdf
V3cube
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
Essential Content-centric Plugins for your Website
Laura Byrne
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
“ONNX and Python to C++: State-of-the-art Graph Compilation,” a Presentation ...
Edge AI and Vision Alliance
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pdf
ghjghvhjgc
 
CapCut Pro PC Crack Latest Version Free Free
josanj305
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
“Computer Vision at Sea: Automated Fish Tracking for Sustainable Fishing,” a ...
Edge AI and Vision Alliance
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
Digital Circuits, important subject in CS
contactparinay1
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Home Cleaning App Development Services.pdf
V3cube
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 

Serverless in Production, an experience report (cloudXchange)