SlideShare a Scribd company logo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Akhtar Hossain
AWS Solutions Architect
Healthcare & Life Science
Sep 12th, 2017
Serverless Orchestration with
AWS Step Functions
Building a Composite Application
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
I have this idea
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Photo sharing app
Metadata
DynamoDB
Extract
metadata &
validate input
Recognize &
Auto Tag
Store
…
Pictures
S3 Bucket
Query &
Search
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
var filemeta = extractImageMetadata(image);
if (!isSupported(metadata)) { err() };
var metadata = transformMetadata(filemeta);
done();
}
Extract the image metadata
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
var filemeta = extractImageMetadata(image);
if (!isSupported(metadata)) { err() };
var metadata = transformMetadata(filemeta);
// image recognition
var labels = recognizePicture(image);
storeImageMetadata([metadata, labels])
done();
}
Use deep learning voodoo for object detection
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
var filemeta = extractImageMetadata(image);
if (!isSupported(metadata)) { err() };
var metadata = transformMetadata(filemeta);
// image recognition
var labels = recognizePicture(image);
storeImageMetadata([metadata, labels])
// generate thumbnail
generateThumbnail(image);
done();
}
Generate thumbnail and store in S3
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
var filemeta = extractImageMetadata(image);
if (!isSupported(metadata)) { err() };
var metadata = transformMetadata(filemeta);
// image recognition
var labels = recognizePicture(image);
storeImageMetadata([metadata, labels])
// generate thumbnail
generateThumbnail(image);
done();
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
var filemeta = extractImageMetadata(image);
if (!isSupported(metadata)) { err() };
var metadata = transformMetadata(filemeta);
// image recognition
var labels = recognizePicture(image);
storeImageMetadata([metadata, labels])
// generate thumbnail
generateThumbnail(image);
done();
}Everything should really be Microservices / Lambda functions, right?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image, done, err) {
// metadata
extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => recognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
Make sure we have our callbacks
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image) {
// metadata
return extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => rekognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
What happens if that line fails?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image) {
// metadata
return extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => rekognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
Can these two be done in parallel?
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image) {
// metadata
return extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => rekognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
This code is “dumb main function” (but hard to get right)
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition
StoreMetadata
Thumbnail
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image) {
// metadata
return extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => rekognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition
StoreMetadata
Thumbnail
Queues and Notification
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
function handle(image) {
// metadata
return extractImageMetadata(image)
.then((img, meta) => isSupported(metadata) … )
.then((img, meta) => transform(metadata) … )
// image recognition
.then((img, meta) => rekognizePicture(img) … )
.then((img, meta, labels) => storeImageMetadata … )
// generate thumbnail
.then((img, meta, labels) =>
generateThumbnail(image) … );
}
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition
Thumbnail
StoreMetadata
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Photo sharing app
Metadata
DynamoDB
Extract
metadata &
validate input
Recognize &
Auto Tag
Store
…
Pictures
S3 Bucket
Query &
Search
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
…
Photo sharing app
Pictures
S3 Bucket
Start Workflow
Lambda
Processing Workflow
Step Functions
Extract
Lambda
Recognize
Lambda
Store
Lambda
Metadata
DynamoDB
Object Detection
Rekognition
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Demo
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
“I want to sequence functions”
“I want to run functions in parallel”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/finally”
“I have code that runs for hours”
• Scales out
• Doesn’t lose state
• Deals with errors/timeouts
• Easy to build & operate
• Auditable
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
{
"StartAt": "ExtractImageMetadata",
"States": {
"ExtractImageMetadata": {
"Type": "Task",
"Next": “ImageTypeCheck”
},
…
}
}
Define in JSON and Then
Visualize in the Console
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Execute One or One Million
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Step Functions Building Blocks
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
Seven State Types
Task: a single unit of work
Synchronous: Lambda
{
"ExtractImageMetadata": {
"Type": "Task",
"Resource": "arn:aws:lambda:mars-ter …”,
…
}
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
Seven State Types
Task: a single unit of work
Asynchronous: “Activity Task”, Polled by workers
{
"ExtractImageMetadata": {
"Type": ”Task",
"Resource": "arn:aws:states:mars-ter …”,
…
}
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
API Actions on Activity Task
Register Activity Task - Returns ARN
Poll For task (by ARN)
Report Success
Report Failure
Report Heartbeat
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Use Activity Task for Manual Approval
Step Functions
Poll
taskToken
Amazon
SES
Poller
Approver
Send success
taskToken
API
Gateway
https://aws.amazon.com/blogs/compute/
implementing-serverless-manual-approval-steps-in-aws-
step-functions-and-amazon-api-gateway/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Use Activity Task for Calling Asynchronous APIs
Step Functions
Poll
taskToken
Amazon
Elastic
Transcoder
Poller
SNS
Send success
taskToken
Lambda Amazon Confidential
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
Seven State Types
NotSupported
Choice: Adds branching logic
{
"ExtractImageMetadata": {
"Type": ”Choice",
”Choices": [{
”Variable": ”…",
”StringEquals": ”…",
”Next": ”…",
}
],
”Default": ”NotSupported",
…
}
}
Task: a single unit of work
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
Seven State Types
NotSupported
Choice: Adds branching logic
Task: a single unit of work
Fail: Stops an execution and mark as failure
Success: Stops an execution successfully
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
StoreMetadata
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
Start
End
Seven State Types
Choice: Adds branching logic
Task: A single unit of work
Parallel: fork and join data across tasks
Fail: Stops an execution and mark as failure
Success: Stops an execution successfully
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Seven State Types
Choice: a single unit of work
Task: a single unit of work
Parallel: fork and join data across tasks
Fail: Stops an execution and mark as failure
Success: Stops an execution successfully
Pass: passes inputs to its outputs
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Document Processing
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Seven State Types
Choice: a single unit of work
Task: a single unit of work
Parallel: fork and join data across tasks
Fail: Stops an execution and mark as failure
Success: Stops an execution successfully
Pass: passes inputs to its outputs
Wait: wait until n seconds.
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Use Wait + Choice to Wait for AWS Batch Job
while:
sleep (30)
if status=done:
break
https://aws.amazon.com/blogs/compute/building-high-throughput-
genomics-batch-workflows-on-aws-workflow-layer-part-4-of-4/
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Seven State Types
Choice: a single unit of work
Task: a single unit of work
Parallel: fork and join data across tasks
Fail: Stops an execution and mark as failure
Success: Stops an execution successfully
Pass: passes inputs to its outputs
Wait: wait until n seconds.
ExtractImageMetadata
ImageTypeCheck
TransformMetadata
Rekognition Thumbnail
StoreMetadata
Start
End
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
"Access Media": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:FindMedia",
"TimeoutSeconds": 2,
"Next": "Graceful Exit",
"Retry": [
{
"ErrorEquals": [ "States.Timeout" ],
"IntervalSeconds": 2, "MaxAttempts": 2, "BackoffRate": 1.5
}
],
"Catch": [
{ "ErrorEquals": [ "States.ALL" ], "Next": "Clean Up" }
]
},
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Use Cases
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
“I want to sequence functions”
With	AWS	Step	Functions,	we	can	easily	change	and	iterate	
on	the	application	workflow	of	our	food	delivery	service	in	
order	to	optimize	operations	and	continually	improve	
delivery	times.	AWS	Step	Functions	lets	us	dynamically	scale	
the	steps	in	our	food	delivery	algorithm	so	we	can	manage	
spikes	in	customer	orders	and	meet	demand.			
Mathias	Nitzsche,	CTO,	foodpanda
“
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Order Fulfillment
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
“I want to select functions based on data”
With AWS Step Functions, it was easy to build a multi-step product
updating system to ensure our database and website always have the
latest price and availability information.
AWS Step Functions let us replace a manual updating process with an
automated series of steps, including built-in retry conditions and error
handling, so we can reliably scale before a big show, and keep pace
with rapidly changing fashions.
Jared Browarnik, CTO, TheTake
“
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Business Processes
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
“I want try/catch/finally”
AWS Step Functions makes it simple to coordinate information
from many different infrastructure systems using easy to design
workflows and create a more intelligent monitoring system for our
Platform as a Service (PaaS).
With AWS Step Functions, we can reliably automate monitoring
decisions and actions in order to reduce human intervention by
over 60%, which improves infrastructure operation productivity and
customer application availability on our platform.
Pedro Pimenta, VP R&D, OutSystems
“
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
13 AWS Lambda Task States
6 Choice States
1 Fail State
DevOps Automation
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Integrate with other AWS services
• Create state machines and Activities with AWS
CloudFormation
• Call AWS Step Functions with Amazon API Gateway
• Start state machines in response to events, or on a
schedule, with Amazon CloudWatch Events
• Monitor state machine executions with Amazon CloudWatch
• Log API calls with AWS CloudTrail
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Input/Output Processing
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Input/Output Processing
State [x]"InputPath" "ResultPath" "OutputPath"
Input
Output
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
InputPath example
{
”s3key”:”apple.png”,
”timestamp”:12324
}
Input
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
InputPath example
{
”s3key”:”apple.png”,
”timestamp”:12324
}
"InputPath”:“$”
Input
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
InputPath example
{
”s3key”:”apple.png”,
”timestamp”:12324
}
State [x]"InputPath”:“$”
Input
Input received by state x:
{
”s3key”:”apple.png”,
”timestamp”:12324
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
InputPath example
"InputPath”:“$.s3key”
{
”s3key”:”apple.png”,
”timestamp”:12324
}
State [x]"InputPath”:“$”
Input
Input received by state x:
{
”s3key”:”apple.png”,
”timestamp”:12324
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
InputPath example
State [y]"InputPath”:“$.s3key”
{
”s3key”:”apple.png”,
”timestamp”:12324
}
”apple.png”
State [x]"InputPath”:“$”
Input
Input received by state y:
Input received by state x:
{
”s3key”:”apple.png”,
”timestamp”:12324
}
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ResultPath example
{
”s3key”:”apple.png”,
”timestamp”:12324
}
Input
State [x]
State output:
{“type”: “png"}
"InputPath”
: “$”
”ResultPath”:“$”{ ”type”:”png}Output
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
ResultPath example
{
”s3key”:”apple.png”,
”timestamp”:12324
}
Input
State [x]
State output:
{“type”: “png"}
"InputPath”
: “$.s3key”
”ResultPath”:“$”{ ”type”:”png}Output
”ResultPath”:“$.metadata”
{
”s3key”:”apple.png”,
”timestamp”:12324,
“metadata”: {
“type”: “png"}
}
Output
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Where does transient application
state live?
In the machine, in JSON texts
passing from state to state.A:
Q:
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reservedhttps://states-language.net/spec
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
2.5¢
How much?
per thousand
state transitions
4,000 free
transitions/month
Free tier:
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
“I want to sequence functions”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/finally”
Is this you?
“I have code that runs for hours”
“I want to run functions in parallel”
© 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
Resources
• Github repo:
https://github.com/awslabs/lambda-refarch-imagerecognition
• Blogs, reference architectures, tutorials
https://aws.amazon.com/step-functions/getting-started
• Amazon States Language
https://states-language.net/spec.html
• Statelint
https://github.com/awslabs/statelint
Thank You!
Don’t Forget Evaluations!

More Related Content

Similar to Serverless Orchestration with AWS Step Functions - DevDay Austin 2017

Build, Train & Deploy Your ML Application on Amazon SageMaker
Build, Train & Deploy Your ML Application on Amazon SageMakerBuild, Train & Deploy Your ML Application on Amazon SageMaker
Build, Train & Deploy Your ML Application on Amazon SageMaker
Amazon Web Services
 
Incident Response on AWS - A Practical Look.pdf
Incident Response on AWS - A Practical Look.pdfIncident Response on AWS - A Practical Look.pdf
Incident Response on AWS - A Practical Look.pdf
Amazon Web Services
 
Practical Guidance for Increasing your Serverless Application's Security
Practical Guidance for Increasing your Serverless Application's SecurityPractical Guidance for Increasing your Serverless Application's Security
Practical Guidance for Increasing your Serverless Application's Security
Chris Munns
 
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
Amazon Web Services
 
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
Amazon Web Services
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
James Ward
 
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
Amazon Web Services
 
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
Amazon Web Services
 
Demystifying Machine Learning on AWS
Demystifying Machine Learning on AWSDemystifying Machine Learning on AWS
Demystifying Machine Learning on AWS
Amazon Web Services
 
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Amazon Web Services
 
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
Amazon Web Services
 
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
Amazon Web Services
 
Exploring CameraX from JetPack
Exploring CameraX from JetPackExploring CameraX from JetPack
Exploring CameraX from JetPack
Hassan Abid
 
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
Amazon Web Services
 
Getting started with rails active storage wae
Getting started with rails active storage waeGetting started with rails active storage wae
Getting started with rails active storage wae
Bishal Khanal
 
Build, train and deploy your ML models with Amazon Sage Maker
Build, train and deploy your ML models with Amazon Sage MakerBuild, train and deploy your ML models with Amazon Sage Maker
Build, train and deploy your ML models with Amazon Sage Maker
AWS User Group Bengaluru
 
Building a Serverless AI Powered Twitter Bot: Collision 2018
Building a Serverless AI Powered Twitter Bot: Collision 2018Building a Serverless AI Powered Twitter Bot: Collision 2018
Building a Serverless AI Powered Twitter Bot: Collision 2018
Amazon Web Services
 
Where ml ai_heavy
Where ml ai_heavyWhere ml ai_heavy
Where ml ai_heavy
Randall Hunt
 
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
Martijn van Dongen
 

Similar to Serverless Orchestration with AWS Step Functions - DevDay Austin 2017 (20)

Build, Train & Deploy Your ML Application on Amazon SageMaker
Build, Train & Deploy Your ML Application on Amazon SageMakerBuild, Train & Deploy Your ML Application on Amazon SageMaker
Build, Train & Deploy Your ML Application on Amazon SageMaker
 
Incident Response on AWS - A Practical Look.pdf
Incident Response on AWS - A Practical Look.pdfIncident Response on AWS - A Practical Look.pdf
Incident Response on AWS - A Practical Look.pdf
 
Practical Guidance for Increasing your Serverless Application's Security
Practical Guidance for Increasing your Serverless Application's SecurityPractical Guidance for Increasing your Serverless Application's Security
Practical Guidance for Increasing your Serverless Application's Security
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018
 
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
[NEW LAUNCH!] Introducing Amazon Elastic Inference: Reduce Deep Learning Infe...
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
 
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
ML Workflows with Amazon SageMaker and AWS Step Functions (API325) - AWS re:I...
 
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
Get Started with Deep Learning and Computer Vision Using AWS DeepLens (AIM316...
 
Demystifying Machine Learning on AWS
Demystifying Machine Learning on AWSDemystifying Machine Learning on AWS
Demystifying Machine Learning on AWS
 
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
Building Content Recommendation Systems Using Apache MXNet and Gluon - MCL402...
 
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
Video anomaly detection using Amazon SageMaker, AWS DeepLens, & AWS IoT Green...
 
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
Building WhereML, an AI Powered Twitter Bot for Guessing Locations of Picture...
 
Exploring CameraX from JetPack
Exploring CameraX from JetPackExploring CameraX from JetPack
Exploring CameraX from JetPack
 
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
Enhancing Media Workflows with Machine Learning (MAE303) - AWS re:Invent 2018
 
Getting started with rails active storage wae
Getting started with rails active storage waeGetting started with rails active storage wae
Getting started with rails active storage wae
 
Build, train and deploy your ML models with Amazon Sage Maker
Build, train and deploy your ML models with Amazon Sage MakerBuild, train and deploy your ML models with Amazon Sage Maker
Build, train and deploy your ML models with Amazon Sage Maker
 
Building a Serverless AI Powered Twitter Bot: Collision 2018
Building a Serverless AI Powered Twitter Bot: Collision 2018Building a Serverless AI Powered Twitter Bot: Collision 2018
Building a Serverless AI Powered Twitter Bot: Collision 2018
 
Where ml ai_heavy
Where ml ai_heavyWhere ml ai_heavy
Where ml ai_heavy
 
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
CloudFormation techniques from the Dutch trenches (DVC07) - AWS re:Invent 2018
 

More from Amazon Web Services

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Amazon Web Services
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Amazon Web Services
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
Amazon Web Services
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
Amazon Web Services
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
Amazon Web Services
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
Amazon Web Services
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Amazon Web Services
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
Amazon Web Services
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Amazon Web Services
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
Amazon Web Services
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
Amazon Web Services
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Amazon Web Services
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
Amazon Web Services
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Amazon Web Services
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWSAmazon Web Services
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckAmazon Web Services
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without serversAmazon Web Services
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...Amazon Web Services
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
Amazon Web Services
 

More from Amazon Web Services (20)

Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
Come costruire servizi di Forecasting sfruttando algoritmi di ML e deep learn...
 
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
Big Data per le Startup: come creare applicazioni Big Data in modalità Server...
 
Esegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS FargateEsegui pod serverless con Amazon EKS e AWS Fargate
Esegui pod serverless con Amazon EKS e AWS Fargate
 
Costruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWSCostruire Applicazioni Moderne con AWS
Costruire Applicazioni Moderne con AWS
 
Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot Come spendere fino al 90% in meno con i container e le istanze spot
Come spendere fino al 90% in meno con i container e le istanze spot
 
Open banking as a service
Open banking as a serviceOpen banking as a service
Open banking as a service
 
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
Rendi unica l’offerta della tua startup sul mercato con i servizi Machine Lea...
 
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...OpsWorks Configuration Management: automatizza la gestione e i deployment del...
OpsWorks Configuration Management: automatizza la gestione e i deployment del...
 
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows WorkloadsMicrosoft Active Directory su AWS per supportare i tuoi Windows Workloads
Microsoft Active Directory su AWS per supportare i tuoi Windows Workloads
 
Computer Vision con AWS
Computer Vision con AWSComputer Vision con AWS
Computer Vision con AWS
 
Database Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatareDatabase Oracle e VMware Cloud on AWS i miti da sfatare
Database Oracle e VMware Cloud on AWS i miti da sfatare
 
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJSCrea la tua prima serverless ledger-based app con QLDB e NodeJS
Crea la tua prima serverless ledger-based app con QLDB e NodeJS
 
API moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e webAPI moderne real-time per applicazioni mobili e web
API moderne real-time per applicazioni mobili e web
 
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatareDatabase Oracle e VMware Cloud™ on AWS: i miti da sfatare
Database Oracle e VMware Cloud™ on AWS: i miti da sfatare
 
Tools for building your MVP on AWS
Tools for building your MVP on AWSTools for building your MVP on AWS
Tools for building your MVP on AWS
 
How to Build a Winning Pitch Deck
How to Build a Winning Pitch DeckHow to Build a Winning Pitch Deck
How to Build a Winning Pitch Deck
 
Building a web application without servers
Building a web application without serversBuilding a web application without servers
Building a web application without servers
 
Fundraising Essentials
Fundraising EssentialsFundraising Essentials
Fundraising Essentials
 
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
AWS_HK_StartupDay_Building Interactive websites while automating for efficien...
 
Introduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container ServiceIntroduzione a Amazon Elastic Container Service
Introduzione a Amazon Elastic Container Service
 

Serverless Orchestration with AWS Step Functions - DevDay Austin 2017

  • 1. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved. Akhtar Hossain AWS Solutions Architect Healthcare & Life Science Sep 12th, 2017 Serverless Orchestration with AWS Step Functions Building a Composite Application
  • 2. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved I have this idea
  • 3. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Photo sharing app Metadata DynamoDB Extract metadata & validate input Recognize & Auto Tag Store … Pictures S3 Bucket Query & Search
  • 4. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata var filemeta = extractImageMetadata(image); if (!isSupported(metadata)) { err() }; var metadata = transformMetadata(filemeta); done(); } Extract the image metadata
  • 5. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata var filemeta = extractImageMetadata(image); if (!isSupported(metadata)) { err() }; var metadata = transformMetadata(filemeta); // image recognition var labels = recognizePicture(image); storeImageMetadata([metadata, labels]) done(); } Use deep learning voodoo for object detection
  • 6. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata var filemeta = extractImageMetadata(image); if (!isSupported(metadata)) { err() }; var metadata = transformMetadata(filemeta); // image recognition var labels = recognizePicture(image); storeImageMetadata([metadata, labels]) // generate thumbnail generateThumbnail(image); done(); } Generate thumbnail and store in S3
  • 7. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata var filemeta = extractImageMetadata(image); if (!isSupported(metadata)) { err() }; var metadata = transformMetadata(filemeta); // image recognition var labels = recognizePicture(image); storeImageMetadata([metadata, labels]) // generate thumbnail generateThumbnail(image); done(); }
  • 8. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata var filemeta = extractImageMetadata(image); if (!isSupported(metadata)) { err() }; var metadata = transformMetadata(filemeta); // image recognition var labels = recognizePicture(image); storeImageMetadata([metadata, labels]) // generate thumbnail generateThumbnail(image); done(); }Everything should really be Microservices / Lambda functions, right?
  • 9. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image, done, err) { // metadata extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => recognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } Make sure we have our callbacks
  • 10. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image) { // metadata return extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => rekognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } What happens if that line fails?
  • 11. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image) { // metadata return extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => rekognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } Can these two be done in parallel?
  • 12. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image) { // metadata return extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => rekognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } This code is “dumb main function” (but hard to get right) ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition StoreMetadata Thumbnail
  • 13. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image) { // metadata return extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => rekognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition StoreMetadata Thumbnail Queues and Notification
  • 14. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved function handle(image) { // metadata return extractImageMetadata(image) .then((img, meta) => isSupported(metadata) … ) .then((img, meta) => transform(metadata) … ) // image recognition .then((img, meta) => rekognizePicture(img) … ) .then((img, meta, labels) => storeImageMetadata … ) // generate thumbnail .then((img, meta, labels) => generateThumbnail(image) … ); } ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata
  • 15. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End
  • 16. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Photo sharing app Metadata DynamoDB Extract metadata & validate input Recognize & Auto Tag Store … Pictures S3 Bucket Query & Search
  • 17. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved … Photo sharing app Pictures S3 Bucket Start Workflow Lambda Processing Workflow Step Functions Extract Lambda Recognize Lambda Store Lambda Metadata DynamoDB Object Detection Rekognition
  • 18. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Demo
  • 19. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End “I want to sequence functions” “I want to run functions in parallel” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” “I have code that runs for hours” • Scales out • Doesn’t lose state • Deals with errors/timeouts • Easy to build & operate • Auditable
  • 20. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End { "StartAt": "ExtractImageMetadata", "States": { "ExtractImageMetadata": { "Type": "Task", "Next": “ImageTypeCheck” }, … } } Define in JSON and Then Visualize in the Console
  • 21. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Execute One or One Million ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End
  • 22. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Step Functions Building Blocks
  • 23. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End Seven State Types Task: a single unit of work Synchronous: Lambda { "ExtractImageMetadata": { "Type": "Task", "Resource": "arn:aws:lambda:mars-ter …”, … } }
  • 24. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End Seven State Types Task: a single unit of work Asynchronous: “Activity Task”, Polled by workers { "ExtractImageMetadata": { "Type": ”Task", "Resource": "arn:aws:states:mars-ter …”, … } }
  • 25. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved API Actions on Activity Task Register Activity Task - Returns ARN Poll For task (by ARN) Report Success Report Failure Report Heartbeat
  • 26. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Use Activity Task for Manual Approval Step Functions Poll taskToken Amazon SES Poller Approver Send success taskToken API Gateway https://aws.amazon.com/blogs/compute/ implementing-serverless-manual-approval-steps-in-aws- step-functions-and-amazon-api-gateway/
  • 27. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Use Activity Task for Calling Asynchronous APIs Step Functions Poll taskToken Amazon Elastic Transcoder Poller SNS Send success taskToken Lambda Amazon Confidential
  • 28. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End Seven State Types NotSupported Choice: Adds branching logic { "ExtractImageMetadata": { "Type": ”Choice", ”Choices": [{ ”Variable": ”…", ”StringEquals": ”…", ”Next": ”…", } ], ”Default": ”NotSupported", … } } Task: a single unit of work
  • 29. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End Seven State Types NotSupported Choice: Adds branching logic Task: a single unit of work Fail: Stops an execution and mark as failure Success: Stops an execution successfully
  • 30. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved StoreMetadata ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail Start End Seven State Types Choice: Adds branching logic Task: A single unit of work Parallel: fork and join data across tasks Fail: Stops an execution and mark as failure Success: Stops an execution successfully
  • 31. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Seven State Types Choice: a single unit of work Task: a single unit of work Parallel: fork and join data across tasks Fail: Stops an execution and mark as failure Success: Stops an execution successfully Pass: passes inputs to its outputs ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End
  • 32. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Document Processing
  • 33. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Seven State Types Choice: a single unit of work Task: a single unit of work Parallel: fork and join data across tasks Fail: Stops an execution and mark as failure Success: Stops an execution successfully Pass: passes inputs to its outputs Wait: wait until n seconds. ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End
  • 34. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Use Wait + Choice to Wait for AWS Batch Job while: sleep (30) if status=done: break https://aws.amazon.com/blogs/compute/building-high-throughput- genomics-batch-workflows-on-aws-workflow-layer-part-4-of-4/
  • 35. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Seven State Types Choice: a single unit of work Task: a single unit of work Parallel: fork and join data across tasks Fail: Stops an execution and mark as failure Success: Stops an execution successfully Pass: passes inputs to its outputs Wait: wait until n seconds. ExtractImageMetadata ImageTypeCheck TransformMetadata Rekognition Thumbnail StoreMetadata Start End
  • 36. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved "Access Media": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:FindMedia", "TimeoutSeconds": 2, "Next": "Graceful Exit", "Retry": [ { "ErrorEquals": [ "States.Timeout" ], "IntervalSeconds": 2, "MaxAttempts": 2, "BackoffRate": 1.5 } ], "Catch": [ { "ErrorEquals": [ "States.ALL" ], "Next": "Clean Up" } ] },
  • 37. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Use Cases
  • 38. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved “I want to sequence functions” With AWS Step Functions, we can easily change and iterate on the application workflow of our food delivery service in order to optimize operations and continually improve delivery times. AWS Step Functions lets us dynamically scale the steps in our food delivery algorithm so we can manage spikes in customer orders and meet demand. Mathias Nitzsche, CTO, foodpanda “
  • 39. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Order Fulfillment
  • 40. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved “I want to select functions based on data” With AWS Step Functions, it was easy to build a multi-step product updating system to ensure our database and website always have the latest price and availability information. AWS Step Functions let us replace a manual updating process with an automated series of steps, including built-in retry conditions and error handling, so we can reliably scale before a big show, and keep pace with rapidly changing fashions. Jared Browarnik, CTO, TheTake “
  • 41. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Business Processes
  • 42. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved “I want try/catch/finally” AWS Step Functions makes it simple to coordinate information from many different infrastructure systems using easy to design workflows and create a more intelligent monitoring system for our Platform as a Service (PaaS). With AWS Step Functions, we can reliably automate monitoring decisions and actions in order to reduce human intervention by over 60%, which improves infrastructure operation productivity and customer application availability on our platform. Pedro Pimenta, VP R&D, OutSystems “
  • 43. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved 13 AWS Lambda Task States 6 Choice States 1 Fail State DevOps Automation
  • 44. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Integrate with other AWS services • Create state machines and Activities with AWS CloudFormation • Call AWS Step Functions with Amazon API Gateway • Start state machines in response to events, or on a schedule, with Amazon CloudWatch Events • Monitor state machine executions with Amazon CloudWatch • Log API calls with AWS CloudTrail
  • 45. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Input/Output Processing
  • 46. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Input/Output Processing State [x]"InputPath" "ResultPath" "OutputPath" Input Output
  • 47. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved InputPath example { ”s3key”:”apple.png”, ”timestamp”:12324 } Input
  • 48. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved InputPath example { ”s3key”:”apple.png”, ”timestamp”:12324 } "InputPath”:“$” Input
  • 49. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved InputPath example { ”s3key”:”apple.png”, ”timestamp”:12324 } State [x]"InputPath”:“$” Input Input received by state x: { ”s3key”:”apple.png”, ”timestamp”:12324 }
  • 50. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved InputPath example "InputPath”:“$.s3key” { ”s3key”:”apple.png”, ”timestamp”:12324 } State [x]"InputPath”:“$” Input Input received by state x: { ”s3key”:”apple.png”, ”timestamp”:12324 }
  • 51. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved InputPath example State [y]"InputPath”:“$.s3key” { ”s3key”:”apple.png”, ”timestamp”:12324 } ”apple.png” State [x]"InputPath”:“$” Input Input received by state y: Input received by state x: { ”s3key”:”apple.png”, ”timestamp”:12324 }
  • 52. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ResultPath example { ”s3key”:”apple.png”, ”timestamp”:12324 } Input State [x] State output: {“type”: “png"} "InputPath” : “$” ”ResultPath”:“$”{ ”type”:”png}Output
  • 53. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved ResultPath example { ”s3key”:”apple.png”, ”timestamp”:12324 } Input State [x] State output: {“type”: “png"} "InputPath” : “$.s3key” ”ResultPath”:“$”{ ”type”:”png}Output ”ResultPath”:“$.metadata” { ”s3key”:”apple.png”, ”timestamp”:12324, “metadata”: { “type”: “png"} } Output
  • 54. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Where does transient application state live? In the machine, in JSON texts passing from state to state.A: Q:
  • 55. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reservedhttps://states-language.net/spec
  • 56. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved
  • 57. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved 2.5¢ How much? per thousand state transitions 4,000 free transitions/month Free tier:
  • 58. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved “I want to sequence functions” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” Is this you? “I have code that runs for hours” “I want to run functions in parallel”
  • 59. © 2017, Amazon Web Services, Inc. or its Affiliates. All rights reserved Resources • Github repo: https://github.com/awslabs/lambda-refarch-imagerecognition • Blogs, reference architectures, tutorials https://aws.amazon.com/step-functions/getting-started • Amazon States Language https://states-language.net/spec.html • Statelint https://github.com/awslabs/statelint