la serverless framework meetup
TRANSCRIPT
Serverless Meetup, Los AngelesDecember 7, 2016
Lessons Learned: Creating an API w/ the Serverless Framework, AWS Lambda & API Gateway
Lessons Learned!
● Make sure it’s the right project
● Monitor your lambdas
● Understand container reuse
Quick tips● Offline local dev: serverless-offline
○ https://github.com/dherault/serverless-offline
● Logging: sls logs -t
● Avoid native modules
○ If you must: https://aws.amazon.com/blogs/compute/nodejs-packages-in-lambda/
● Use NodeJS 4.3, it’s what Lambda uses!
#1: Make sure it’s the right project
Good Candidates
Background workersEvent-Driven Tasks
Rely on Dynamic Scaling
Bad Candidates
Low Latency APIsNon-“spikey” workloads
#2: Monitor your funcs
● Monitor every invocation● Metrics available: duration, # invocations, mem, cpu, errors,
cold starts● Log/metrics correlation● Detect leaks (memory, file descriptor)● Cold start reporting● Stack traces● Realtime dashboard, email reports● Coming soon: triggers/alerts, distributed tracing
Get early access at - iopipe.com
● Containers get reused and recycled● fd leaks, service handles (e.g. databases)● Filesystem usage (e.g. /tmp)● Cold starts after inactivity (~5m)● Cold starts after 4h no matter what!
#3: Understand container reuse