Slide 1

Slide 1 text

Scale your Node Application, Forget the Infrastructure Taking the Next Step with AWS Lambda Matthew Williams Evangelist @ Datadog [email protected] | @technovangelist DevOpsDays Boston Organizer

Slide 2

Slide 2 text

The plan § Introduction § Coding § Debugging § Orchestration § Lambda Setup § Deployment § Monitoring

Slide 3

Slide 3 text

Introduction to Lambda • Key Concepts • Serverless • Stateless • Trigger-based • What a Lambda Function is • Your executable code (Nodejs 4.3/6.10, C#, Java, Python) • No restrictions • Priced based on execution time and memory

Slide 4

Slide 4 text

Available Lambda Triggers • S3 • DynamoDB • Kinesis Streams • Simple Notification Service • Simple Email Service • Cognito • CloudFormation • CloudWatch Logs • CloudWatch Events • CodeCommit • Scheduled Events (powered by CloudWatch Events) • Echo • Lex • API Gateway • Invoked via the AWS CLI/APIs

Slide 5

Slide 5 text

Other Lambda Triggers • Zapier • Twilio • Others?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Coding

Slide 20

Slide 20 text

SOA/Microservices One function - one purpose Fine grained

Slide 21

Slide 21 text

Scalable Inputs and Outputs Lambda is very scalable Is your database as scalable

Slide 22

Slide 22 text

Check if data exists Most probably stateless BUT…container could be reused Check if data exists in /tmp (500MB) If using a database, look into context.callbackWaitsForEmptyEventLoop

Slide 23

Slide 23 text

Think about error handling DLQ SNS or SQS

Slide 24

Slide 24 text

Debugging

Slide 25

Slide 25 text

Use Modules with Local Harness • All the logic should be in Modules • The Handler should just be a minimal wrapper • Why? • Easier to run tests on the code • Easier to run locally with a local harness

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

AWS X-Ray

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Orchestration

Slide 32

Slide 32 text

Universal Event Stream

Slide 33

Slide 33 text

Step Functions

Slide 34

Slide 34 text

Lambda Setup

Slide 35

Slide 35 text

Minimal but Specific Security • Your IAM roles should allow the minimum privileges • If you only need to read, don’t also allow write

Slide 36

Slide 36 text

Choosing the right memory • As you increase memory, you get more CPU

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

Choosing the right timeout • Stick with the default unless you need more

Slide 39

Slide 39 text

Deployment

Slide 40

Slide 40 text

Frameworks node-lambda

Slide 41

Slide 41 text

CloudFormation + SAM

Slide 42

Slide 42 text

Tagging

Slide 43

Slide 43 text

Monitoring

Slide 44

Slide 44 text

What are the Lambda Metrics aws.lambda.duration, min, max, sum aws.lambda.errors aws.lambda.invocations aws.lambda.iterator_age aws.lambda.throttles aws.lambda.deadlettererrors

Slide 45

Slide 45 text

Three options for monitoring Lambda 1. Add a custom metric to CloudWatch 2. Add metric directly to monitoring application 3. Add a line to the CloudWatch logs

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

Scale your Node Application, Forget the Infrastructure Taking the Next Step with AWS Lambda Matthew Williams Evangelist @ Datadog [email protected] | @technovangelist DevOpsDays Boston Organizer