Slide 1

Slide 1 text

© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Matt Williams, Evangelist @ Datadog [email protected], @technovangelist Monitoring, Hold the Infrastructure Getting the most out of AWS Lambda

Slide 2

Slide 2 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 3

Slide 3 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 4

Slide 4 text

Datadog Overview SaaS-based Infrastructure Monitoring Focus on Modern Infrastructure (cloud, containers, micro-services) Processing about a trillion metrics per day Intelligent alerting

Slide 5

Slide 5 text

Monitor Everything

Slide 6

Slide 6 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 7

Slide 7 text

What is AWS Lambda The next stage in a long progression... physical boxes virtual machines on physical boxes containers lambda AWS instances

Slide 8

Slide 8 text

Physical Boxes • Pre-defined resources & capacity • Variable consumption but paying for 100% • Scalability relies on getting new hardware • Other costs (power, cooling, maintenance, etc) physical boxes

Slide 9

Slide 9 text

VM on Physical Boxes • Scalability: VM level; Abstraction: HW level • Similar physical resources, capacity, scalability • Flexible VM resources & capacity • Paying for 100% of hardware • Variable consumption on each VM plus overhead physical box vm vm vm vm vm vm

Slide 10

Slide 10 text

AWS Instances • Scalability: VM level, abstraction: HW level, no physical restrictions • Paying for 100% of instance • Variable consumption • Much easier to scale each VM virtual machines on physical boxes AWS instances

Slide 11

Slide 11 text

Containers • Much more flexible, variable consumption • Paying for 100% of instance • No VM overhead • Scalability at the app level, abstraction at OS level virtual machines on physical boxes AWS/VM/ Physical ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr ctr

Slide 12

Slide 12 text

AWS Lambda • Much more flexible, variable consumption • Paying time and memory used by the function • Scalability at the function level, abstraction at runtime level • Very early days lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda lambda

Slide 13

Slide 13 text

Important AWS Lambda Concepts TRIGGER BASED CC BY-SA 2.0: https://commons.wikimedia.org/wiki/File:Roy_Rogers_Prints_at_the_Chinese_Theatre.jpg

Slide 14

Slide 14 text

Important AWS Lambda Concepts STATELESS STATELESS

Slide 15

Slide 15 text

Important Lambda Concepts SERVERLESS AS FAR AS YOU ARE CONCERNED CC BY 2.0: https://commons.wikimedia.org/wiki/File:Chapa_traffic_jam_in_Maputo_(9717216968).jpg

Slide 16

Slide 16 text

What is a AWS Lambda Function Each AWS Lambda Function is: • Executable code in a container on LXC on AMZN Linux • Container implementation hidden from user • No restrictions on what it can do • Built-in runtimes for Java, Node, Python • Other languages supported through exec/spawn • Priced based on execution time, quantity, and memory

Slide 17

Slide 17 text

What can trigger AWS Lambda? Files (S3) Database Updates (DynamoDB) Streams (Kinesis) Messages (SNS, SES) User Data & Authentication (Cognito) Infrastructure Changes (CloudFormation) Logs, Events, Metrics (CloudWatch) IoT (Echo, API Gateway)

Slide 18

Slide 18 text

Concurrency Each event will trigger a new Lambda function There is a safety limit per region of 100 (contact support for changes)

Slide 19

Slide 19 text

So What Are Some Good Use Cases Bootstrapping a startup (first 1M requests/month free, up to 3.2M free seconds / month) Cron File manipulation (transcode, compress, etc) API translation Stream processing (social media analysis) Scaling infrastructure Mobile/IoT Backends

Slide 20

Slide 20 text

https://goad.io/

Slide 21

Slide 21 text

Benchling CRISPR Searches Genome searching Few 100k searches per month 90 GB of genome data 1. A web server receives a request to do CRISPR search 2. The web server splits up the genome into smaller regions. 3. The web server invokes the Lambda function for each region. 4. Results are combined and returned to the user. Old infrastructure cost $1000’s per month; New scales better and costs $60 per month http://benchling.engineering/crispr-aws-lambda/

Slide 22

Slide 22 text

Best Practices from AWS • Write stateless style code; ensure no affinity between code and underlying compute infrastructure • Avoid declaring variables outside scope of handler • Set +rx permissions in uploaded ZIP • Minimize use of startup code not processing current event • Monitor your Lambdas to view and optimize req latencies • Delete old Lambda functions https://docs.aws.amazon.com/lambda/lates t/dg/best-practices.html

Slide 23

Slide 23 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 24

Slide 24 text

How to Create a AWS Lambda Function 1. Write the code (Node, Java, Python, anything via exec/spawn) 2. Setup on AWS (memory, timeout, role, handler, invocation) • Web interface • node-lambda, apex, serverless, etc 3. Debug • logs

Slide 25

Slide 25 text

AWS Lambda Demo

Slide 26

Slide 26 text

Other AWS Lambda Tools • Apex (http://apex.run) • Serverless framework (http://serverless.com) • AWS Chalice (https://github.com/awslabs/chalice)

Slide 27

Slide 27 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

Collecting data is cheap

Slide 31

Slide 31 text

Collecting data is cheap; Not having it when you need it can be expensive

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

The Plan Datadog overview The what and the why of AWS Lambda Adding AWS Lambda to your infrastructure Monitoring 101 (the tl;dr version) Adding AWS Lambda to your monitoring

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

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

Slide 42

Slide 42 text

The Downsides of the First Two • CloudWatch Metrics • CloudWatch metrics are updated every minute • Send more than one per minute and you get a histogram • Directly to Monitoring App • Adds complexity and size to your lambda (should be kept small) • But no lag time

Slide 43

Slide 43 text

How Datadog Does It Add line to CloudWatch logs: MONITORING|unix_epoch_timestamp|value|type| my.metric.name|#tag1:value,tag2 metric type can be count or gauge In Python: print(monitoringstring) In NodeJS: console.log(monitoringstring)

Slide 44

Slide 44 text

Monitoring example

Slide 45

Slide 45 text

Monitor All the AWS Lambda Things Monitor the triggers Monitor the function Monitor the output

Slide 46

Slide 46 text

Examples • Stream processing pipeline • each message gets a new lambda invocation • monitor duration of each step • tag based on data in the message, other metadata • dashboards that look at the data in new ways

Slide 47

Slide 47 text

Examples • Image processing app • different size images are uploaded • resized to standard sizes • monitor performance per size, other metadata

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Summary AWS Lambda can be an interesting part of your infrastructure Very low cost to start Serverless doesn’t mean monitorless Matt Williams - [email protected] @technovangelist https://github.com/awslabs?query=lambda Twitter: @technovangelist

Slide 51

Slide 51 text

No content