71
Orchestrating Lambda with Step Functions

Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

Orchestrating Lambda with Step Functions

Page 2: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 3: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 4: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 5: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 6: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 7: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Who am I

Matt Williams

Evangelist at Datadog@[email protected]

Organizer of DevOps Days Boston 2017 & 2018

Page 8: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Who is Datadog

SaaS-based Monitoring & Analytics Infrastructure, APM, LogsOpen Source AgentTrillions of data

points per day

We are hiring!!

Page 9: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

I l ike to talk about Serverless…

Page 10: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

What is AWS Lambda

ServerlessAs far as you are concernedDon’t pay for idleScale with ease

FaaSNode 8.10 (java, go, python, c#)

Trigger-based

Page 11: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Trigger Based?

S3DynamoDBKinesisSNSSESCognitoCloudFormationCloudwatch Logs & Events

CodeCommitConfigAlexaLexAPI GatewayIoTCloudFrontLambda

Page 12: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

AWS Lambda

Page 13: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 14: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 15: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

That’s pretty cool right? But not perfect

You still have to configure everything elseS3DynamoDBAPI GWetc

SAMCloudformationServerless

Page 16: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

AWS Lambda

Page 17: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

…but serverless !== ec2

Page 18: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

…but serverless !== applications

Page 19: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

…applications are complicated

Page 20: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

…serverless functions should respect the single responsibility principle…

Page 21: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 22: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 23: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

we can create many serverless functions

Page 24: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

we can create many serverless functions

but how do we orchestrate them?

Page 25: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Event/Message/Database as Traffic Cop

Amazon Kinesis Amazon SQS Amazon DynamoDB

Page 26: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.

https://github.com/Nordstrom/hello-retail

Page 27: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Enter AWS Step Functions

Page 28: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

What about Azure?

Page 29: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

a step function is

Page 30: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

a step function is

a state machine

Page 31: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

but what about SWF?(Amazon Simple Workflow Service)

Page 32: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

AWS Step Function Concepts

State MachineStates

TaskChoiceSucceed/FailPassWaitParallel

TransitionsExecutions

You define the State Machine with the Amazon States Language

A diagram will be generated based on that structure

Page 33: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Task

Page 34: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Choice

Page 35: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Succeed / Fail

Page 36: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Pass

Page 37: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Wait

Page 38: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

State Example: Parallel

Page 39: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Many ways to build Step Functions

I used Serverless Framework

Page 40: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Benefits of Serverless Framework

Define everything in a single file:IAM Role StatementsLambda Function HandlersLambda Function TriggersStep Function StatesCloudFormation for other things

Page 41: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Amazon ECRAWS

Lambda

AmazonS3

AmazonDynamoDB

Amazon CloudFront

AWS CodeBuild

AWS CodeCommit

AWSCloudFormation

IAM

Amazon API Gateway*

AWS Step Functions

AmazonSNS

Page 42: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 43: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 44: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 45: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 46: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 47: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 48: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

1.Use ML to figure out which slide2.Is this slide different than the last time?3.If so, pull slide data from Dynamo4.If slide different then create document

in s35.Build the site6.Wait for it

1.Is it built7.Done

Page 49: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Type: TaskResource: Lambda Function

Page 50: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 51: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 52: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Type: TaskResource: Lambda Function

Page 53: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 54: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 55: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Type: TaskResource: Lambda Function

Page 56: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 57: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Type: TaskResource: Lambda Function

Page 58: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 59: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)
Page 60: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

How about monitoring?

We monitor Lambda via Logs

MONITORING|unix_epoch_timestamp|value|count|my.metric.name|#tag1:value,tag2

console.log(monitoringstring);

Page 61: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

What are the Lambda Metrics

aws.lambda.duration, min, max, sumaws.lambda.errorsaws.lambda.invocationsaws.lambda.throttlesaws.lambda.iterator_age

Page 62: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

What are the Step Function Metrics

aws.states.execution_time (.maximum, .minimum)aws.states.executions_aborted, failed, started, succeeded, timed_outaws.states.lambda_functions_scheduled, started, succeeded, timed_outaws.states.execution_throttledaws.states.lambda_function_time (.maximum, .minimum)aws.states.lambda_function_run_time (.maximum, .minimum)aws.states.lambda_function_schedule_time (.maximum, .minimum)aws.states.lambda_functions_started

Page 63: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 64: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 65: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 66: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 67: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 68: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Page 69: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Lambda and Step Function Challenges

• Logging and debugging is a bit…painful• Don’t trust the SF when it claims a step is complete• Cold start is a thing but it may not be as bad as you think. • Cold start is a thing and it could be worse than you think• Every Lambda should do one thing…except if you can’t

afford it

@technovangelist

Page 70: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Summary

Step Functions make AWS Lambda orchestration easyLambda, Serverless, and Step Functions can be an interesting part of your infrastructureMonitor your Lambda functions to ensure peak performance

Source can be found at:https://github.com/DataDog/mattw-reinvent2017-demo

Page 71: Orchestrating AWS Lambda with Step Functions · What is AWS Lambda Serverless As far as you are concerned Don’t pay for idle Scale with ease FaaS Node 8.10 (java, go, python, c#)

@technovangelist

Matt Williams

Evangelist at Datadog@[email protected]

Organizer of DevOps Days Boston 2017 & 2018