serverless in production, an experience report (buildstuff)
TRANSCRIPT
![Page 1: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/1.jpg)
from the
TRENCHESTRENCHES
what you should know before you go to production
AWS LAMBDAAWS LAMBDA
![Page 3: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/3.jpg)
Yan Cui
Server Architect
Principal Engineer
Lead Developer
Senior Developer
http://theburningmonk.com
@theburningmonk
Senior Developer
![Page 4: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/4.jpg)
Yan Cui
Server Architect
Principal Engineer
Lead Developer
Senior Developer
http://theburningmonk.com
@theburningmonk
Senior Developer
![Page 5: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/5.jpg)
![Page 6: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/6.jpg)
![Page 7: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/7.jpg)
apr, 2016
![Page 8: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/8.jpg)
hidden complexities and dependencies
low utilisation to leave room for traffic spikes
EC2 scaling is slow, so scale earlier
lots of cost for unused resources
up to 30 mins for deployment
deployment required downtime
![Page 9: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/9.jpg)
- Dan North
“lead time to someone saying thank you is the only reputation
metric that matters.”
![Page 10: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/10.jpg)
![Page 11: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/11.jpg)
“what would good
look like for us?”
![Page 12: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/12.jpg)
be small be fast
have zero downtime have no lock-step
DEPLOYMENTS SHOULD...
![Page 13: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/13.jpg)
FEATURES SHOULD...be deployable independently
be loosely-coupled
![Page 14: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/14.jpg)
WE WANT TO...minimise cost for unused resources
minimise ops effort reduce tech mess
deliver visible improvements faster
![Page 15: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/15.jpg)
nov, 2016
![Page 16: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/16.jpg)
170 Lambda functions in prod
1.2 GB deployment packages in prod
95% cost saving vs EC2
15x no. of prod releases per month
![Page 17: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/17.jpg)
timeis a good fit
![Page 18: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/18.jpg)
1st function in prod!time
is a good fit
![Page 19: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/19.jpg)
?
timeis a good fit
1st function in prod!
![Page 20: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/20.jpg)
ALERTING
CI / CD
TESTING
LOGGING
MONITORING
![Page 21: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/21.jpg)
Practices ToolsPrinciples
what is good? how to make it good? with what?
![Page 22: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/22.jpg)
Principles outlast Tools
![Page 23: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/23.jpg)
170 functions
WOOF!
? ?
timeis a good fit
1st function in prod!
![Page 24: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/24.jpg)
SECURITY
DISTRIBUTEDTRACING
CONFIGMANAGEMENT
![Page 25: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/25.jpg)
evolving the PLATFORM
![Page 26: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/26.jpg)
rebuilt search
![Page 27: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/27.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearch
![Page 28: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/28.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
![Page 29: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/29.jpg)
new analytics pipeline
![Page 30: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/30.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Google BigQuery
![Page 31: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/31.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Google BigQuery
1 developer, 2 daysdesign production
(his 1st serverless project)
![Page 32: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/32.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Google BigQuery“nothing ever got done
this fast at Skype!”
- Chris Twamley
![Page 33: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/33.jpg)
- Dan North
“lead time to someone saying thank you is the only reputation
metric that matters.”
![Page 34: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/34.jpg)
Rebuiltwith Lambda
![Page 35: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/35.jpg)
![Page 36: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/36.jpg)
![Page 37: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/37.jpg)
![Page 38: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/38.jpg)
![Page 39: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/39.jpg)
![Page 40: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/40.jpg)
![Page 41: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/41.jpg)
Rebuiltwith Lambda
![Page 42: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/42.jpg)
BigQuery
![Page 43: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/43.jpg)
BigQuery
![Page 44: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/44.jpg)
grapheneDB
BigQuery
![Page 45: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/45.jpg)
grapheneDB
BigQuery
![Page 46: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/46.jpg)
grapheneDB
BigQuery
![Page 47: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/47.jpg)
getting PRODUCTION READY
![Page 48: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/48.jpg)
CHOOSE A
FRAMEWORK
DEPLOYMENT
![Page 50: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/50.jpg)
https://github.com/awslabs/serverless-application-model
![Page 56: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/56.jpg)
TESTING
![Page 58: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/58.jpg)
Level of Testing
1.Unitdo our objects do the right thing?are they easy to work with?
![Page 59: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/59.jpg)
![Page 60: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/60.jpg)
Level of Testing
1.Unit2.Integrationdoes our code work against code we can’t change?
![Page 61: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/61.jpg)
handler
![Page 62: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/62.jpg)
handler
test by invoking the handler
![Page 63: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/63.jpg)
Level of Testing
1.Unit2.Integration3.Acceptancedoes the whole system work?
![Page 64: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/64.jpg)
Level of Testing
unit
integration
acceptance
feedb
ack
confidence
![Page 65: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/65.jpg)
“…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
![Page 66: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/66.jpg)
“…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
![Page 67: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/67.jpg)
Don’t Mock Types You Can’t ChangeServices
![Page 68: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/68.jpg)
Paul Johnston
The serverless approach to testing is different and may
actually be easier.
http://bit.ly/2t5viwK
![Page 69: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/69.jpg)
LambdaAPI Gateway DynamoDB
![Page 70: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/70.jpg)
LambdaAPI Gateway DynamoDB
Unit Tests
![Page 71: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/71.jpg)
LambdaAPI Gateway DynamoDB
Unit Tests
Mock/Stub
![Page 72: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/72.jpg)
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…
![Page 73: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/73.jpg)
![Page 74: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/74.jpg)
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
![Page 75: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/75.jpg)
![Page 76: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/76.jpg)
But it slows down my feedback loop…
IT’S NOT ABOUT YOU!
![Page 77: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/77.jpg)
…if a service can’t provide you with a relatively easy
way to test the interface in reality, then you should
consider using another one.
Paul Johnston
![Page 78: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/78.jpg)
“…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
![Page 79: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/79.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
![Page 80: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/80.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Test Input
![Page 81: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/81.jpg)
Legacy Monolith Amazon Kinesis Amazon Lambda
Amazon CloudSearchAmazon API Gateway Amazon Lambda
Test Input
Validate
![Page 82: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/82.jpg)
integration tests exercise system’s Integration with its
external dependencies
my code
![Page 83: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/83.jpg)
acceptance tests exercise system End-to-End from
the outside
my code
![Page 84: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/84.jpg)
integration tests differ from acceptance tests only in HOW the
Lambda functions are invoked
observation
![Page 85: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/85.jpg)
![Page 86: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/86.jpg)
![Page 87: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/87.jpg)
![Page 88: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/88.jpg)
CI + CD PIPELINE
![Page 89: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/89.jpg)
“the earlier you consider CI + CD, the more time you save in the long run”
- me
![Page 90: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/90.jpg)
“…We prefer to have the end-to-end tests exercise both the system and the process by which it’s built and deployed…
This sounds like a lot of effort (it is), but has to be done anyway repeatedly during the software’s lifetime…”
Testing End-to-End
![Page 91: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/91.jpg)
“deployment scripts that only live on the CI
box is a disaster waiting to happen”
- me
![Page 92: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/92.jpg)
Jenkins build config deploys and tests
unit + integration tests
deploy
acceptance tests
![Page 93: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/93.jpg)
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
![Page 94: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/94.jpg)
build.sh allows repeatable builds on both local & CI
![Page 95: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/95.jpg)
![Page 96: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/96.jpg)
Auto Auto Manual
![Page 97: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/97.jpg)
LOGGING
![Page 98: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/98.jpg)
![Page 99: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/99.jpg)
2016-07-12T12:24:37.571Z 994f18f9-482b-11e6-8668-53e4eab441ae GOT is off air, what do I do now?
![Page 100: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/100.jpg)
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
![Page 101: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/101.jpg)
function name
date
function version
![Page 102: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/102.jpg)
me
Logs are not easily searchable in CloudWatch Logs.
![Page 103: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/103.jpg)
LOG OVERLOAD
![Page 104: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/104.jpg)
CENTRALISE LOGS
![Page 105: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/105.jpg)
CENTRALISE LOGS
MAKE THEM EASILYSEARCHABLE
![Page 106: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/106.jpg)
+ +the elk stack
![Page 107: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/107.jpg)
CloudWatch Logs
![Page 108: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/108.jpg)
CloudWatch Logs AWS Lambda ELK stack
![Page 109: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/109.jpg)
CloudWatch Events
![Page 110: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/110.jpg)
![Page 112: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/112.jpg)
DISTRIBUTED TRACING
![Page 113: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/113.jpg)
![Page 114: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/114.jpg)
“my followers didn’t receive my new post!”
- a user
![Page 115: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/115.jpg)
where could the problem be?
![Page 116: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/116.jpg)
correlation IDs*
* eg. request-id, user-id, yubl-id, etc.
![Page 117: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/117.jpg)
ROLL YOUR OWNCLIENTS
![Page 118: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/118.jpg)
kinesis client
http client
sns client
![Page 120: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/120.jpg)
ROLL YOUR OWNCLIENTS
X-RAY
![Page 121: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/121.jpg)
Amazon X-Ray
![Page 122: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/122.jpg)
Amazon X-Ray
![Page 123: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/123.jpg)
traces do not span over API Gateway
![Page 125: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/125.jpg)
MONITORING + ALERTING
![Page 126: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/126.jpg)
“where do I install monitoring agents?”
![Page 127: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/127.jpg)
you can’t
![Page 128: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/128.jpg)
• invocation Count• error Count• latency• throttling• granular to the minute• support custom metrics
![Page 129: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/129.jpg)
• same metrics as CW• better dashboard• support custom metrics
https://www.datadoghq.com/blog/monitoring-lambda-functions-datadog/
![Page 130: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/130.jpg)
![Page 131: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/131.jpg)
![Page 132: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/132.jpg)
![Page 133: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/133.jpg)
my code
![Page 134: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/134.jpg)
my code
![Page 135: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/135.jpg)
my codeinternet internet
press button something happens
![Page 136: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/136.jpg)
“how do I batch up and send logs in the
background?”
![Page 137: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/137.jpg)
you can’t (kinda)
![Page 138: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/138.jpg)
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
![Page 139: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/139.jpg)
CloudWatch Logs AWS Lambda
ELK stacklogs
metrics
CloudWatch
![Page 141: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/141.jpg)
DASHBOARDS
![Page 142: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/142.jpg)
DASHBOARDS
SET ALARMS
![Page 143: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/143.jpg)
DASHBOARDS
SET ALARMS
TRACK APP-LEVELMETRICS
![Page 144: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/144.jpg)
Not Only CloudWatch
![Page 145: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/145.jpg)
![Page 146: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/146.jpg)
“you really don't want your monitoring
system to fail at the same time as the
system it monitors” - me
![Page 147: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/147.jpg)
CONFIG MANAGEMENT
![Page 148: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/148.jpg)
easily and quickly propagate config changes
![Page 149: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/149.jpg)
![Page 150: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/150.jpg)
me
Environment variables make it hard to share configurations
across functions.
![Page 151: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/151.jpg)
me
Environment variables make it hard to implement fine-grained
access to sensitive info.
![Page 152: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/152.jpg)
CENTRALISEDCONFIG SERVICE
![Page 153: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/153.jpg)
config servicegoes here
![Page 154: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/154.jpg)
![Page 155: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/155.jpg)
![Page 156: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/156.jpg)
![Page 157: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/157.jpg)
SSM Parameter
Store
![Page 158: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/158.jpg)
sensitive data should be encrypted in-flight, and at rest
(credentials, connection string, etc.)
![Page 159: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/159.jpg)
role-based access
![Page 160: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/160.jpg)
SSM Parameter Store
HTTPS
role-based access
encrypted in-flight
![Page 161: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/161.jpg)
SSM Parameter Store
encrypt
role-based access
![Page 162: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/162.jpg)
SSM Parameter Store
encrypted at-rest
![Page 163: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/163.jpg)
HTTPS
role-based access
SSM Parameter Store
encrypted in-flight
![Page 164: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/164.jpg)
CENTRALISEDCONFIG SERVICE
CLIENT LIBRARY
![Page 165: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/165.jpg)
fetch & cache at Cold Start
![Page 166: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/166.jpg)
invalidate at interval + signal
![Page 168: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/168.jpg)
PRO TIPS
![Page 169: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/169.jpg)
max 75 GB total deployment package size*
* limit is per AWS region
![Page 170: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/170.jpg)
Janitor Monkey
![Page 172: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/172.jpg)
disable versionFunctions in
![Page 173: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/173.jpg)
install Serverless framework as dev dependency at project level
dev dependencies are excluded since 1.16.0
![Page 176: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/176.jpg)
UNDERSTANDCOLDSTARTS
![Page 177: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/177.jpg)
Amazon X-Ray1st invocation
2nd invocation
cold start
![Page 183: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/183.jpg)
EMBRACENODE.JS & PYTHON
![Page 184: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/184.jpg)
what about type safety?
![Page 185: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/185.jpg)
![Page 186: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/186.jpg)
complexity ceiling of a Node.js app
com
plex
ity
![Page 187: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/187.jpg)
complexity ceiling of a Node.js app
com
plex
ity
referential transparencyimmutability as default
type inferenceoption typesunion types
…
![Page 188: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/188.jpg)
for managing complexity
complexity ceiling of a Node.js app
com
plex
ity
referential transparencyimmutability as default
type inferenceoption typesunion types
…
![Page 189: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/189.jpg)
complexity ceiling of a Node.js app
com
plex
ity
complexity ceiling of a Node.js Lambda function
![Page 190: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/190.jpg)
if you can limit the complexity of your solution, maybe you
won’t need the tools for managing that complexity.me
![Page 191: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/191.jpg)
AVOIDCOLDSTARTS
![Page 192: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/192.jpg)
CloudWatch Event AWS Lambda
![Page 193: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/193.jpg)
CloudWatch Event AWS Lambda
ping
ping
ping
ping
![Page 194: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/194.jpg)
CloudWatch Event AWS Lambda
ping
ping
ping
ping
![Page 195: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/195.jpg)
CloudWatch Event AWS Lambda
ping
ping
ping
ping
HEALTH CHECKS?
![Page 196: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/196.jpg)
AVOID HARDASSUMPTIONS
ABOUT FUNCTIONLIFETIME
![Page 197: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/197.jpg)
USE STATE FOR
OPTIMISATION
![Page 198: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/198.jpg)
max 5 mins execution time
![Page 199: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/199.jpg)
USE RECURSIONFOR LONG
RUNNING TASKS
![Page 200: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/200.jpg)
CONSIDERPARTIAL
FAILURES
![Page 201: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/201.jpg)
“AWS Lambda polls your stream and invokes your Lambda function. Therefore, if
a Lambda function fails, AWS Lambda attempts to process the erring batch of
records until the time the data expires…”
http://docs.aws.amazon.com/lambda/latest/dg/retries-on-errors.html
![Page 202: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/202.jpg)
should function fail on partial/any failures?
![Page 203: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/203.jpg)
SNS
Kinesis
SQS
after 3 attempts
share processing logic
events are processed in chronological order
failed events are retried out of sequence
![Page 204: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/204.jpg)
PROCESS SQSWITH RECURSIVE
FUNCTIONS
![Page 206: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/206.jpg)
AVOID HOTKINESS
STREAMS
![Page 207: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/207.jpg)
“Each shard can support up to 5 transactions per second for reads, up to a maximum total data
read rate of 2 MB per second.”
http://docs.aws.amazon.com/streams/latest/dev/service-sizes-and-limits.html
![Page 208: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/208.jpg)
“If your stream has 100 active shards, there will be 100 Lambda functions running concurrently. Then, each
Lambda function processes events on a shard in the order that they arrive.”
http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html
![Page 209: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/209.jpg)
when no. of processors goes up…
![Page 210: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/210.jpg)
ReadProvisionedThroughputExceeded
can have too many Kinesis read operations…
![Page 211: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/211.jpg)
ReadRecords.IteratorAge
unpredictable spikes in read ‘latency’…
![Page 212: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/212.jpg)
can kinda workaround…
![Page 214: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/214.jpg)
clever, but costly
![Page 215: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/215.jpg)
for subsystems that don’t have to be realtime, or are task-
based (ie. order doesn’t matter), consider other
triggers such as S3 or SNS.me
![Page 216: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/216.jpg)
@theburningmonktheburningmonk.comgithub.com/theburningmonk
![Page 217: Serverless in production, an experience report (BuildStuff)](https://reader031.vdocument.in/reader031/viewer/2022022415/5a6764da7f8b9ab0378b47ef/html5/thumbnails/217.jpg)
@theburningmonktheburningmonk.comgithub.com/theburningmonk
http://bit.ly/2yQZj1H
all my blog posts on Lambda