SlideShare a Scribd company logo
© 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
AWS Step Functions을 활용한
서버리스 앱 오케스트레이션
Sun Yong
Developer Specialist Solutions Architect
ASEAN
Lambda - Serverless
Microservices
Atomic self-contained units of code;
Easy to develop, deploy and share
Follow JSON/REST/HTTPS
paradigm
Serverless
Develop, run and scale apps and
microservices without provisioning
and managing servers
Seeing a big shift towards..
Architecture Viewpoint Shift Service Viewpoint Shift
Strong relations with each other
Let’s take a look at the evolution of computing
Physical servers
in datacenters
Virtual servers
in datacenters
Virtual servers
in the cloud
Each progressive step was better
Physical Servers
Datacenters
Virtual Servers
Datacenters
• Higher utilization
• Faster provisioning speed
• Improved uptime
• Disaster recovery
• Hardware independence
• Trade CAPEX for OPEX
• More scale
• Elastic resources
• Faster speed and agility
• Reduced maintenance
• Better availability and
fault tolerance
Virtual servers
in the cloud
But there are still limitations
Physical Servers
Datacenters
Virtual Servers
Datacenters
• Trade CAPEX for OPEX
• More scale
• Elastic resources
• Faster speed and agility
• Reduced maintenance
• Better availability and
fault tolerance
• Still need to administer
virtual servers
• Still need to manage
capacity and utilization
• Still need to size
workloads
• Still need to manage
availability, fault tolerance
• Still expensive to run
intermittent jobs
Virtual servers
in the cloud
Evolving
to serverless
SERVERLESS
Virtual servers
in the cloud
Physical servers
in data centers
Virtual servers
in data centers
No server is easier to manage than no server
All of these responsibilities
go away
Provisioning and utilization
Availability and fault tolerance
Scaling
Operations and management
What’s the benefit?
Serverless is a form of event-driven computing
Event Driven Computing
Function as a Service
Serverless
EVENT DRIVEN CONTINUOUS SCALING PAY BY USAGE
Deliver on demand, never pay for idle
Lambda ++
λλ
λ DBMS
λ
λ
λ
λ
λ
λ λ
λ
λ
Queue
Modern
serverless
app
Modern
serverless
app
“I want to sequence functions”
“I want to select functions based on data”
“I want to retry functions”
“I want try/catch/finally”
Functions into apps
“I have code that runs for hours”
“I want to run functions in parallel”
The Twelve Factor App
In the modern era, software is commonly delivered as a service: called web apps, or software-as-
a-service. The twelve-factor app is a methodology for building software-as-a-service apps that:
• Use declarative formats for setup automation, to minimize time and cost for new developers
joining the project;
• Have a clean contract with the underlying operating system, offering maximum portability
between execution environments;
• Are suitable for deployment on modern cloud platforms, obviating the need for servers and
systems administration;
• Minimize divergence between development and production, enabling continuous
deployment for maximum agility;
• And can scale up without significant changes to tooling, architecture, or development
practices.
https://12factor.net/ko/
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
Coordination by method call
λ λ
λ
λ
λ
λ
λ
Coordination by function chaining
λ
λ
λ
λ
λλ
λ
Coordination by database
λλ
λ
λ
λλ
λ
Coordination by queues
λ
λ
λ
λ λλ
λ
Coordination must-haves
• Scales out
• Doesn’t lose state
• Deals with errors/timeouts
• Easy to build & operate
• Auditable
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
Application Lifecycle in AWS Step Functions
Visualize in the
Console
Define in JSON Monitor
Executions
Define in JSON and Then Visualize in the Console
{
”Comment”: “Hello World Example",
"StartAt” : "HelloWorld”,
"States” : {
"HelloWorld” : {
"Type” : "Task",
"Resource” :
"arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTI
ON_NAME”,
"End” : true
}
}
}
Execute One or One Million
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Start
End
HelloWorld
Monitor Executions from the Console
Seven State Types
Task A single unit of work
Choice Adds branching logic
Parallel Fork and join the data across tasks
Wait Delay for a specified time
Fail Stops an execution and marks it as a failure
Succeed Stops an execution successfully
Pass Passes its input to its output
Build Visual Workflows from State Types
Task
Choice
Fail
Parallel
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
How it works – API-level
Create State Machine – input is a machine spec
in a JSON DSL
Run Machine – input JSON blob, returns
Execution ID
List Executions
Describe Execution
Stop Execution
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
Serverless Human Approval Tasks
https://aws.amazon.com/blogs/compute/
implementing-serverless-manual-approval-steps-in-aws-step-functions-and-amazon-api-gateway/
Image Recognition and Processing Backend
Task
Choice
Fail
Parallel
https://github.com/awslabs/lambda-refarch-imagerecognition
Amazon EBS Snapshot Management
https://github.com/awslabs/aws-step-functions-ebs-snapshot-mgmt
1. Tag
2. Count
3. Copy to DR region
4. Delete Expired
Whenever a new EBS
snapshot completes:
State Machines
invoked by Amazon
CloudWatch Events
Use Case
“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
“
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
var Twit = require('twit');
var T = new Twit(require('botfiles/config.js'));
exports.handler = function myBot(event, context, callback) {
var list = event.inputList;
var textToTweet = list.shift();
var output = { inputList: list }
T.post('statuses/update',
{ status: textToTweet }, function(err, reply) {
if (err) {
console.log('error:', err); context.fail();
} else {
console.log('tweet:', reply); callback(null, output);
}
});
};
“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
“
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
"ChoiceState": {
"Type" : "Choice",
"Choices": [
{
"Variable": "$.productSource",
"StringEquals": "screen-scrape",
"Next": "ScreenScrapeState"
},{
"Variable": "$.productSource",
"StringEquals": "vendor-a",
"Next": "VendorA"
},{
"Variable": "$.productSource",
"StringEquals": "vendor-b",
"Next": "VendorB"
},
{
"Variable": "$.productSource",
"StringEquals": "vendor-c",
"Next":"VendorC"
},{
"Variable": "$.productSource",
"StringEquals": "updateProduct",
"Next":"UpdateProduct"
}
],
"Default": "ScreenScrapeState”
}
“I want to retry functions”
We get transient errors from a RESTful
service we depend on, once every four
or five times we call it. But if we keep
retrying, it eventually works.
“
{
"Comment": "Call out to a RESTful service",
"StartAt": "Call out",
"States": {
"Call out": {
"Type": "Task",
"Resource":
"arn:aws:lambda:eu-central-1:123456789012:function:RestCallout",
"Retry": [
{ "ErrorEquals": [ "HandledError" ], "MaxAttempts": 10 }
],
"End": true
}
}
}
“I want to run functions in parallel”
We want to send the captured image to
three OCR providers and take the result
with the highest confidence value.“
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
"Send for OCR": {
"Type": "Parallel",
"Next": "Pick result",
"Branches": [
{
"StartAt": "Prep1",
"States": {
"Prep1": {
"Type": "Pass",
"Result": { "inputList": [ "OCR Provider 1" ] },
"Next": "Go1"
},
"Go1": {
"Type": "Task",
"Resource": "arn:aws:lambda:eu-central-1:123456789012:function:StatesBot",
"End": true
}
}
Where does transient application
state live?
In the machine, in JSON texts
passing from state to state.A:
Q:
Input processing
{
"title": "Numbers to add",
"numbers": [ 3, 4 ]
}
{
"Type": "Task",
"InputPath": "$.numbers",
"Resource": "arn:aws:lambda…"
…
[ 3, 4 ]
Raw input:
State spec:
Task input:
Input processing
Q: InputPath not provided?
A: State gets raw input as-is.
Q: InputPath is null?
A: State gets an empty JSON object: {}
Q: InputPath produces plural output?
A: State gets it wrapped in a JSON array.
Result placement
{
"title": "Numbers to add",
"numbers": [ 3, 4 ]
}
{
"Type": "Task",
"InputPath": "$.numbers",
"ResultPath": "$.sum”,
…
Raw input:
State spec:
Output: {
"title": "Numbers to add",
"numbers": [ 3, 4 ],
”sum": 7
}
Result placement
Q: ResultPath not provided?
A: Input is discarded; raw output is used.
Q: ResultPath is null?
A: State input is state output.
Q: ResultPath produces plural output?
A: Not allowed, validator won’t accept.
“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
“
13 AWS Lambda Task States
6 Choice States
1 Fail State
“I want try/catch/finally”
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
"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" }
]
},
“I have code that runs for hours”
We need to gather data from our
production line, in units of 8-hour shifts.
“
More API actions
Register Activity Task - Returns ARN
Poll For task (by ARN)
Report Success
Report Failure
Report Heartbeat
"NextShift": {
"Type": "Wait",
"TimestampPath": "$.ShiftStart",
"Next": "Gather Plant Data"
},
"Gather Plant Data": {
"Type": "Task",
"Resource":
"arn:aws:states:ap-northeast-1:123456789012:activity:PlWatch",
"TimeoutSeconds": 30000,
"HeartBeatSeconds": 120,
"Next": "Clean up"
}
“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”
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
https://states-language.net/spec
AWS Step Functions을 활용한 서버리스 앱 오케스트레이션
Demo
1. Hello World
2. Activity Demo
3. Deep Learning with Step Function
4. AWS Batch
https://github.com/mizti/aws_stepfunc_chainer
2.5¢
How much?
per thousand
state transitions
4,000 free
transitions/month
Free tier:
Q&A

More Related Content

PDF
20150724 제10회 부산 모바일 포럼 - 클라우드컴퓨팅과 함께하는 아마존 웹 서비스
PDF
AWS Media Day-AWS 기반의 미디어 & 엔터테인먼트 워크플로우 소개(Ben Masek 미디어 엔터테인먼트 부서 (M&E) 글로벌...
PDF
메가존과 AWS가 공개하는 AWS 비용 최적화 전략-메가존 김성용 매니저 및 AWS 이우상 매니저:: AWS Cloud Track 3 Ga...
PDF
AWS 클라우드를 통한 교육 및 연구 혁신 - AWS Summit Seoul 2017
PDF
AWS Summit Seoul 2015 - AWS 클라우드를 활용한 빅데이터 및 실시간 스트리밍 분석
PDF
AWS CLOUD 2017 - Amazon Athena 및 Glue를 통한 빠른 데이터 질의 및 처리 기능 소개 (김상필 솔루션즈 아키텍트)
PDF
Partner ConneXions - Partnering with AWS (안영균 이사)
PPTX
Processamento em tempo real usando AWS - padrões e casos de uso
20150724 제10회 부산 모바일 포럼 - 클라우드컴퓨팅과 함께하는 아마존 웹 서비스
AWS Media Day-AWS 기반의 미디어 & 엔터테인먼트 워크플로우 소개(Ben Masek 미디어 엔터테인먼트 부서 (M&E) 글로벌...
메가존과 AWS가 공개하는 AWS 비용 최적화 전략-메가존 김성용 매니저 및 AWS 이우상 매니저:: AWS Cloud Track 3 Ga...
AWS 클라우드를 통한 교육 및 연구 혁신 - AWS Summit Seoul 2017
AWS Summit Seoul 2015 - AWS 클라우드를 활용한 빅데이터 및 실시간 스트리밍 분석
AWS CLOUD 2017 - Amazon Athena 및 Glue를 통한 빠른 데이터 질의 및 처리 기능 소개 (김상필 솔루션즈 아키텍트)
Partner ConneXions - Partnering with AWS (안영균 이사)
Processamento em tempo real usando AWS - padrões e casos de uso

What's hot (7)

PDF
Jeff Barr Amazon Services Cloud Computing
PDF
Em tempo real: Ingestão, processamento e analise de dados
PDF
AWS re:Invent 2016 recap (part 2)
PDF
교육의 진화, 클라우드는 어떤 역할을 하는가 :: Vincent Quah :: AWS Summit Seoul 2016
PDF
New Trends of Geospatial Services on AWS Cloud - Channy Yun :: ICGIS 2015 Seoul
PDF
Premiers pas et bonnes pratiques sur Amazon AWS - Carlos Condé
PDF
Introduction to Amazon Web Services
Jeff Barr Amazon Services Cloud Computing
Em tempo real: Ingestão, processamento e analise de dados
AWS re:Invent 2016 recap (part 2)
교육의 진화, 클라우드는 어떤 역할을 하는가 :: Vincent Quah :: AWS Summit Seoul 2016
New Trends of Geospatial Services on AWS Cloud - Channy Yun :: ICGIS 2015 Seoul
Premiers pas et bonnes pratiques sur Amazon AWS - Carlos Condé
Introduction to Amazon Web Services
Ad

Similar to AWS Step Functions을 활용한 서버리스 앱 오케스트레이션 (20)

PDF
Serverless Apps with AWS Step Functions
PDF
Orchestrating complex workflows with aws step functions
PDF
How to ship customer value faster with step functions
PDF
Step into serverless into the box 2018
PPTX
Aws steps
PDF
Deliver Business Value Faster with AWS Step Functions
PDF
Automating EVA Workflows with AWS Step Functions
PDF
Serverless on AWS: Architectural Patterns and Best Practices
PDF
Delightful steps to becoming a functioning user of Step Functions
PPTX
Serverlessusecase workshop feb3_v2
PDF
The art of the state
PDF
Getting Started with AWS Lambda and Serverless Computing
PPTX
Serverless without Code (Lambda)
PDF
Serverless use cases with AWS Lambda - More Serverless Event
PPTX
Serverless
PPTX
The good, the bad, the ugly side of step functions
PPTX
Primeros pasos en desarrollo serverless
PDF
What's new in Serverless at AWS?
PDF
Aws slide
PPTX
Serverless Generative AI on AWS, AWS User Groups of Florida
Serverless Apps with AWS Step Functions
Orchestrating complex workflows with aws step functions
How to ship customer value faster with step functions
Step into serverless into the box 2018
Aws steps
Deliver Business Value Faster with AWS Step Functions
Automating EVA Workflows with AWS Step Functions
Serverless on AWS: Architectural Patterns and Best Practices
Delightful steps to becoming a functioning user of Step Functions
Serverlessusecase workshop feb3_v2
The art of the state
Getting Started with AWS Lambda and Serverless Computing
Serverless without Code (Lambda)
Serverless use cases with AWS Lambda - More Serverless Event
Serverless
The good, the bad, the ugly side of step functions
Primeros pasos en desarrollo serverless
What's new in Serverless at AWS?
Aws slide
Serverless Generative AI on AWS, AWS User Groups of Florida
Ad

More from Amazon Web Services Korea (20)

PDF
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
PDF
[D3T1S06] Neptune Analytics with Vector Similarity Search
PDF
[D3T1S03] Amazon DynamoDB design puzzlers
PDF
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
PDF
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
PDF
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
PDF
[D3T1S02] Aurora Limitless Database Introduction
PDF
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
PDF
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 2
PDF
AWS Modern Infra with Storage Roadshow 2023 - Day 1
PDF
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
PDF
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
PDF
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
PDF
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
PDF
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
PDF
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
PDF
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
PDF
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
PDF
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...
[D3T1S01] Gen AI를 위한 Amazon Aurora 활용 사례 방법
[D3T1S06] Neptune Analytics with Vector Similarity Search
[D3T1S03] Amazon DynamoDB design puzzlers
[D3T1S04] Aurora PostgreSQL performance monitoring and troubleshooting by use...
[D3T1S07] AWS S3 - 클라우드 환경에서 데이터베이스 보호하기
[D3T1S05] Aurora 혼합 구성 아키텍처를 사용하여 예상치 못한 트래픽 급증 대응하기
[D3T1S02] Aurora Limitless Database Introduction
[D3T2S01] Amazon Aurora MySQL 메이저 버전 업그레이드 및 Amazon B/G Deployments 실습
[D3T2S03] Data&AI Roadshow 2024 - Amazon DocumentDB 실습
AWS Modern Infra with Storage Roadshow 2023 - Day 2
AWS Modern Infra with Storage Roadshow 2023 - Day 1
사례로 알아보는 Database Migration Service : 데이터베이스 및 데이터 이관, 통합, 분리, 분석의 도구 - 발표자: ...
Amazon DocumentDB - Architecture 및 Best Practice (Level 200) - 발표자: 장동훈, Sr. ...
Amazon Elasticache - Fully managed, Redis & Memcached Compatible Service (Lev...
Internal Architecture of Amazon Aurora (Level 400) - 발표자: 정달영, APAC RDS Speci...
[Keynote] 슬기로운 AWS 데이터베이스 선택하기 - 발표자: 강민석, Korea Database SA Manager, WWSO, A...
Demystify Streaming on AWS - 발표자: 이종혁, Sr Analytics Specialist, WWSO, AWS :::...
Amazon EMR - Enhancements on Cost/Performance, Serverless - 발표자: 김기영, Sr Anal...
Amazon OpenSearch - Use Cases, Security/Observability, Serverless and Enhance...
Enabling Agility with Data Governance - 발표자: 김성연, Analytics Specialist, WWSO,...

Recently uploaded (20)

PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
“AI and Expert System Decision Support & Business Intelligence Systems”
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...

AWS Step Functions을 활용한 서버리스 앱 오케스트레이션

  • 1. © 2016, Amazon Web Services, Inc. or its Affiliates. All rights reserved. AWS Step Functions을 활용한 서버리스 앱 오케스트레이션 Sun Yong Developer Specialist Solutions Architect ASEAN
  • 3. Microservices Atomic self-contained units of code; Easy to develop, deploy and share Follow JSON/REST/HTTPS paradigm Serverless Develop, run and scale apps and microservices without provisioning and managing servers Seeing a big shift towards.. Architecture Viewpoint Shift Service Viewpoint Shift Strong relations with each other
  • 4. Let’s take a look at the evolution of computing Physical servers in datacenters Virtual servers in datacenters Virtual servers in the cloud
  • 5. Each progressive step was better Physical Servers Datacenters Virtual Servers Datacenters • Higher utilization • Faster provisioning speed • Improved uptime • Disaster recovery • Hardware independence • Trade CAPEX for OPEX • More scale • Elastic resources • Faster speed and agility • Reduced maintenance • Better availability and fault tolerance Virtual servers in the cloud
  • 6. But there are still limitations Physical Servers Datacenters Virtual Servers Datacenters • Trade CAPEX for OPEX • More scale • Elastic resources • Faster speed and agility • Reduced maintenance • Better availability and fault tolerance • Still need to administer virtual servers • Still need to manage capacity and utilization • Still need to size workloads • Still need to manage availability, fault tolerance • Still expensive to run intermittent jobs Virtual servers in the cloud
  • 7. Evolving to serverless SERVERLESS Virtual servers in the cloud Physical servers in data centers Virtual servers in data centers
  • 8. No server is easier to manage than no server All of these responsibilities go away Provisioning and utilization Availability and fault tolerance Scaling Operations and management What’s the benefit?
  • 9. Serverless is a form of event-driven computing Event Driven Computing Function as a Service Serverless
  • 10. EVENT DRIVEN CONTINUOUS SCALING PAY BY USAGE Deliver on demand, never pay for idle
  • 14. “I want to sequence functions” “I want to select functions based on data” “I want to retry functions” “I want try/catch/finally” Functions into apps “I have code that runs for hours” “I want to run functions in parallel”
  • 15. The Twelve Factor App In the modern era, software is commonly delivered as a service: called web apps, or software-as- a-service. The twelve-factor app is a methodology for building software-as-a-service apps that: • Use declarative formats for setup automation, to minimize time and cost for new developers joining the project; • Have a clean contract with the underlying operating system, offering maximum portability between execution environments; • Are suitable for deployment on modern cloud platforms, obviating the need for servers and systems administration; • Minimize divergence between development and production, enabling continuous deployment for maximum agility; • And can scale up without significant changes to tooling, architecture, or development practices. https://12factor.net/ko/
  • 17. Coordination by method call λ λ λ λ λ λ λ
  • 18. Coordination by function chaining λ λ λ λ λλ λ
  • 21. Coordination must-haves • Scales out • Doesn’t lose state • Deals with errors/timeouts • Easy to build & operate • Auditable
  • 23. Application Lifecycle in AWS Step Functions Visualize in the Console Define in JSON Monitor Executions
  • 24. Define in JSON and Then Visualize in the Console { ”Comment”: “Hello World Example", "StartAt” : "HelloWorld”, "States” : { "HelloWorld” : { "Type” : "Task", "Resource” : "arn:aws:lambda:REGION:ACCOUNT_ID:function:FUNCTI ON_NAME”, "End” : true } } }
  • 25. Execute One or One Million Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld Start End HelloWorld
  • 26. Monitor Executions from the Console
  • 27. Seven State Types Task A single unit of work Choice Adds branching logic Parallel Fork and join the data across tasks Wait Delay for a specified time Fail Stops an execution and marks it as a failure Succeed Stops an execution successfully Pass Passes its input to its output
  • 28. Build Visual Workflows from State Types Task Choice Fail Parallel
  • 30. How it works – API-level Create State Machine – input is a machine spec in a JSON DSL Run Machine – input JSON blob, returns Execution ID List Executions Describe Execution Stop Execution
  • 31. 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
  • 32. Serverless Human Approval Tasks https://aws.amazon.com/blogs/compute/ implementing-serverless-manual-approval-steps-in-aws-step-functions-and-amazon-api-gateway/
  • 33. Image Recognition and Processing Backend Task Choice Fail Parallel https://github.com/awslabs/lambda-refarch-imagerecognition
  • 34. Amazon EBS Snapshot Management https://github.com/awslabs/aws-step-functions-ebs-snapshot-mgmt 1. Tag 2. Count 3. Copy to DR region 4. Delete Expired Whenever a new EBS snapshot completes: State Machines invoked by Amazon CloudWatch Events
  • 36. “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. var Twit = require('twit'); var T = new Twit(require('botfiles/config.js')); exports.handler = function myBot(event, context, callback) { var list = event.inputList; var textToTweet = list.shift(); var output = { inputList: list } T.post('statuses/update', { status: textToTweet }, function(err, reply) { if (err) { console.log('error:', err); context.fail(); } else { console.log('tweet:', reply); callback(null, output); } }); };
  • 40. “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 “
  • 42. "ChoiceState": { "Type" : "Choice", "Choices": [ { "Variable": "$.productSource", "StringEquals": "screen-scrape", "Next": "ScreenScrapeState" },{ "Variable": "$.productSource", "StringEquals": "vendor-a", "Next": "VendorA" },{ "Variable": "$.productSource", "StringEquals": "vendor-b", "Next": "VendorB" }, { "Variable": "$.productSource", "StringEquals": "vendor-c", "Next":"VendorC" },{ "Variable": "$.productSource", "StringEquals": "updateProduct", "Next":"UpdateProduct" } ], "Default": "ScreenScrapeState” }
  • 43. “I want to retry functions” We get transient errors from a RESTful service we depend on, once every four or five times we call it. But if we keep retrying, it eventually works. “
  • 44. { "Comment": "Call out to a RESTful service", "StartAt": "Call out", "States": { "Call out": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:RestCallout", "Retry": [ { "ErrorEquals": [ "HandledError" ], "MaxAttempts": 10 } ], "End": true } } }
  • 45. “I want to run functions in parallel” We want to send the captured image to three OCR providers and take the result with the highest confidence value.“
  • 47. "Send for OCR": { "Type": "Parallel", "Next": "Pick result", "Branches": [ { "StartAt": "Prep1", "States": { "Prep1": { "Type": "Pass", "Result": { "inputList": [ "OCR Provider 1" ] }, "Next": "Go1" }, "Go1": { "Type": "Task", "Resource": "arn:aws:lambda:eu-central-1:123456789012:function:StatesBot", "End": true } }
  • 48. Where does transient application state live? In the machine, in JSON texts passing from state to state.A: Q:
  • 49. Input processing { "title": "Numbers to add", "numbers": [ 3, 4 ] } { "Type": "Task", "InputPath": "$.numbers", "Resource": "arn:aws:lambda…" … [ 3, 4 ] Raw input: State spec: Task input:
  • 50. Input processing Q: InputPath not provided? A: State gets raw input as-is. Q: InputPath is null? A: State gets an empty JSON object: {} Q: InputPath produces plural output? A: State gets it wrapped in a JSON array.
  • 51. Result placement { "title": "Numbers to add", "numbers": [ 3, 4 ] } { "Type": "Task", "InputPath": "$.numbers", "ResultPath": "$.sum”, … Raw input: State spec: Output: { "title": "Numbers to add", "numbers": [ 3, 4 ], ”sum": 7 }
  • 52. Result placement Q: ResultPath not provided? A: Input is discarded; raw output is used. Q: ResultPath is null? A: State input is state output. Q: ResultPath produces plural output? A: Not allowed, validator won’t accept.
  • 53. “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 “
  • 54. 13 AWS Lambda Task States 6 Choice States 1 Fail State “I want try/catch/finally”
  • 56. "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" } ] },
  • 57. “I have code that runs for hours” We need to gather data from our production line, in units of 8-hour shifts. “
  • 58. More API actions Register Activity Task - Returns ARN Poll For task (by ARN) Report Success Report Failure Report Heartbeat
  • 59. "NextShift": { "Type": "Wait", "TimestampPath": "$.ShiftStart", "Next": "Gather Plant Data" }, "Gather Plant Data": { "Type": "Task", "Resource": "arn:aws:states:ap-northeast-1:123456789012:activity:PlWatch", "TimeoutSeconds": 30000, "HeartBeatSeconds": 120, "Next": "Clean up" }
  • 60. “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”
  • 64. Demo
  • 65. 1. Hello World 2. Activity Demo 3. Deep Learning with Step Function 4. AWS Batch
  • 67. 2.5¢ How much? per thousand state transitions 4,000 free transitions/month Free tier:
  • 68. Q&A