la serverless framework meetup

21
Serverless Meetup, Los Angeles December 7, 2016 Lessons Learned: Creating an API w/ the Serverless Framework, AWS Lambda & API Gateway

Upload: marc-campbell

Post on 18-Jan-2017

138 views

Category:

Technology


1 download

TRANSCRIPT

Serverless Meetup, Los AngelesDecember 7, 2016

Lessons Learned: Creating an API w/ the Serverless Framework, AWS Lambda & API Gateway

Marc Campbell Joe Toscano

Serverless

AWS Lambda

Initial Project

Why AWS Lambda?

No Devops Tooling Unlimited* ScalingLower Cost

But… Enterprise...

Multiple Deployment Options

Why Framework?

Deployment Options

Now● AWS Lambda

Soon● Google Cloud Functions● IBM OpenWhisk● Azure Functions

Lambda wasn’t without challenges

Serverless Version

0.5 1.0 RC

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

#2: Monitor your funcs

● 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

Review

No DevopsMostly true. We wrote some chatops, but it was less than writing Ansible scripts.

Lower CostUsually true. Depends on the project.

Infinite ScalabilityTrue.

Multiple Deployment OptionsBecoming true.