0% found this document useful (0 votes)
102 views99 pages

Simpleworkflow in The Cloud: Poa June 17, 2010 Alan Robbins and Rick Sears

The document discusses SimpleWorkflow, a cloud-based workflow service from AWS. It describes how workflows are common but existing BPM products have limitations. SimpleWorkflow aims to provide a simpler, more open architecture for developers by modeling workflows as stateless functions that process history to determine next decisions. It provides core runtime infrastructure while workers can be developed independently in any language. This allows workflows to be easily shared and monetized in a marketplace of capabilities.

Uploaded by

manedeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views99 pages

Simpleworkflow in The Cloud: Poa June 17, 2010 Alan Robbins and Rick Sears

The document discusses SimpleWorkflow, a cloud-based workflow service from AWS. It describes how workflows are common but existing BPM products have limitations. SimpleWorkflow aims to provide a simpler, more open architecture for developers by modeling workflows as stateless functions that process history to determine next decisions. It provides core runtime infrastructure while workers can be developed independently in any language. This allows workflows to be easily shared and monetized in a marketplace of capabilities.

Uploaded by

manedeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 99

SimpleWorkflow in the

Cloud
POA June 17, 2010
Alan Robbins and Rick Sears

Todays Talk

Motivations and Goals


AWS SimpleWorkflow (SWF)
Building Workflows
Workflow Patterns

Synchronous Web Services

A Workflow We All Know


About

Can you recognize a


Workflow?
Most developers dont know of workflows
Im just building my application!
This is simple, I just need a couple of
states

100s of workflows at Amazon right now!


Indicators?

Tasks longer than ~5 seconds


Sweep a database looking for state
Sequence of tasks connected by queues
Polling for activity completion
Distribute tasks to daemons
Background or batch jobs

What is a Workflow?
Multi-step activity orchestration
Business logic relating those activities
Address failures and exceptions

May be long-lived business activities


Asynchronous or event-driven execution
Lasting minutes or months (or longer)
Involve human decision making
Span organizational boundaries

BPM Market Segment

BPM Market Segment


Recognized ubiquitous need
Many standard workflow modeling
languages
BPML, WSFL, WSCL, BPSS, XLANG, WSCI, WSCDL, XAML, jPDL, xPDL, BPEL, YAWL,

Many Sophisticated BPM Software Products


IBM, Tibco, Oracle, Microsoft, JBoss, ...
Most extend a standard or require a
proprietary workflow modeling language

Vast majority of developers still build ad hoc


Huge market opportunity!

BPM Product Architecture


XML-based Workflow Definition

BPM Workflow Engine

Database

Downside of BPM Products


Large up-front costs (besides the $ for
product)
Require users to host the engine and database

Start with an esoteric XML modeling


language
Steep learning curve barrier for developers

Develop within a proprietary framework


Expose external functionality as SOAP endpoints
Add-on ESB technology and build adaptors

Approach is neither flexible nor scalable


Not designed for the cloud

Workflows in the Cloud?

Unique Musts of Cloud


Services

Service, not software product!


Low barrier to entry
Wide appeal
Suitable for mission critical apps
Support any programming language
Inexpensive relative to software
products
No practical scalability limitations
Secure

SimpleWorkflow Design
Goals

Open Architecture for Developers


Low-level Primitives with a Simple API
Provide all the Runtime Infrastructure
Enable users to define workflow
capabilities that are:
Compositional
Customizable
Sharable
Monetizable

Marketplace of Cloud
Capability

Marketplace of Cloud
Capability
Anyone can offer their activities and
workflows
Document API and extension points
Include pricing plans
BUY enables access

SimpleWorkflow brokers all interactions


Authentication, permissions, metering & billing

Amazon to offer capabilities


Utilizing other AWS services (S3 , EMR, MTurk, )
Amazons eCommerce capabilities

How to Accomplish these


Goals?

We had an Insight!

We had an Insight!
For any workflow
Regardless of representation language
Regardless of simplicity or complexity
Even in exceptional situations

At any point in time the decisions


about what to do next can be coded
as a stateless function of what
happened before!

A Decider Represents a
Workflow
Workflow
History
- Events
- Inputs
- Result

Decider
(stateless function)
Decisions

Dont need to define a modeling language!

SimpleWorkflow isnt

SimpleWorkflow
Architecture
SimpleWorkflo
w

Activity Workers

External worker processes


Deployed on multiple hosts
Receive Activity Tasks [Input]
Respond Completed [Result] or Failed

while true {
Poll for Activity Task (long poll)
<execute business activity, script, or
program>
Respond Completed (with Result) or Failed
}

Activity Workers

External worker processes


Deployed on multiple hosts
Receive Activity Tasks [Input]
Respond Completed [Result] or Failed

while true {
Poll for Activity Task (long poll)
<hand off task to a website or other app>
}
Respond Completed (with Result) or Failed

Decider

External worker processes


Deployed on multiple hosts
Receive Workflow Tasks [History]
Respond Completed [Decisions] or Failed

while true {
Poll for Workflow Task (long poll)
<apply decider logic: History Decisions>
Respond Completed (with Decisions) or
Failed
}

Decider is Open
Many innovative
implementation approaches:
Decider Framework [available now]
Annotations Framework
xPDL Interpreter
Asynchrony
?
<domain specific languages>

Worker Protocols
Advantages of polling

Secure: no endpoint exposed to the Internet!


Workers can be located behind corporate firewalls
Automatic throttling and load balancing
Easier to implement for many app types

Downsides of polling
A lot of work for nothing
To reduce latency, clients aggressively poll

Long polling: from Jabber and Comet


Eliminates the downsides of polling

Push protocols will be supported soon


SOAP and REST web services (+ BSF for Amazon
internal)
SNS task delivery

Runtime Infrastructure

Runtime Infrastructure
WF State
Persistence
Task
Synchronization
Scheduling &
Queuing
Timeout
Management
Task Routing
Versioning

Access/Permissio
ns
Monitoring/Metri
cs
Metering and
Billing
Audit Trail
Archival
Console

Simple API
Workflow Instances

Start
Signal
TryCancel
Terminate

Visibility of Instances
List, Describe,
GetHistory

Access/Permissions
Get/SetPolicy, Associate

Activity & Decider


Tasks
PollForTask
Respond
Completed or Failed

Decisions

Schedule Activity
TryCancel Activity
Record Split/Join
Complete Signal
Complete Workflow

Takeaways
Workflows are multi-step asynchronous
capabilities which may be very long lived
Workflows are ubiquitous
You probably have them if you know it or not!

Requires special techniques and infrastructure


SimpleWorkflow is a cloud-centric AWS service
Providing all the infrastructure you need

Marketplace enables sharing and monetization

Building Workflows using


SWF

Two Approaches

Choreography

Orchestration

Choreographies
Participants
coordinate actions
between one another
Everyone must know:
Where to look?
Whom to tell?
How to handle the
unexpected?
How to report status?

Item Processing
Pipeline

Orchestrations
Actions coordinated
by centralized
decision maker
Workers only need
to know:
How to do their job
How to communicate

Centralized status
and failure handling
Apollo deployment

SWFs Role
Both are valid approaches
Recognized need for support for
orchestration approach
SWF acts as auditable coordinator
between:
Decider acting as orchestrator
Activity workers performing specific jobs

Getting Started

First Things First


Break your workflow into pieces
What activities?
What data do they need?
How do they relate to one another?
What do I do when things go wrong?
How do I know whats happening?

Understand how the workflow will


evolve

Next Steps

Tell us about those pieces

Connect Activity Workers


SimpleWorkflo
w

Connect Decider
SimpleWorkflo
w
Decider
(stateless function)
Workflow
History

Decisions

Kick it off!

Designing Complex Systems

Design Patterns
Famous GOF patterns for designing software
Covers common practices in a language
agnostic way
Building blocks of application logic

Some examples:
Creational
Singleton, Factory Method

Structural
Faade

Behavioral
Visitor

Workflow Patterns
Common practices for building multi-step
applications
Building blocks for orchestrating applications
Some examples:
Control
Sequence, Parallel Split, Synchronization,

Data
Data-based Routing, Scope Data,

Exception Handling
Deadline Expiry,

Resource
Retain Familiar,

More Information
Patterns collected and documented
by a team lead by Professor Wil Van
Der Aalst and a team lead by
Professor Arthur ter Hofstede.
More details at:
www.workflowpatterns.com

Patterns and SWF

Control Patterns

Sequence
Structured Loop
Exclusive Choice with Simple Merge
Parallel Split with Synchronization
Persistent Trigger

Sequence

Sequence
Start

A1

A2

A3

Close

Simplest of all patterns


Used with other patterns to form
complex workflows
Also cover Task Data pattern
SWF primitives supporting this pattern:
Scheduling of activities with data
History of events

Start

A1

SimpleWorkfl
ow

A2

A3

Close

History
WorkflowInstanceStarted
WorkflowTaskScheduled

StartWorkflowInsta
nce

Start

A1

A2

Close

History

SimpleWorkfl
ow

PollForWorkflowTas
k

A3

WorkflowInstanceStarted
WorkflowTaskScheduled
Respons
e

Start

A1

A2

A3

Close

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Schedule A1

History

WorkflowTaskCompleted
ActivityTaskScheduled
A1

Start

A1

A2

Close

Activity
Task

SimpleWorkfl
ow

PollForActivityTa
sk

A3

Input_1 = FOO

Respons
e

History

ActivityTaskScheduled
A1
ActivityTaskStarted A1

A1

Start

A1

A2

A3

Close

Result
SimpleWorkfl
ow

RespondActivityTaskCompl
eted

Datum_1 = FOO

History

A1

ActivityTaskStarted A1
ActivityTaskCompleted
A1
WorkflowTaskScheduled

Structured Loop

Structured Loop
n
Start

A1

A2

A3

Close

Deals with bounded re-executions of


steps or collections of steps
Simple example entails retries of single step
Also cover Deadline Expiry exception
handling pattern
SWF features supporting these patterns:
Activity timeouts
Rescheduling activities

Start

A1

A2

Respons
e

A2

Close

History

SimpleWorkfl
ow

PollForActivityTa
sk

A3

ActivityTaskScheduled
A2
ActivityTaskStarted A2

Start

A1

SimpleWorkfl
ow

RespondActivityTaskCompl
eted

A2

A2

A3

Close

Start

A1

A2

Close

History

SimpleWorkfl
ow

PollForWorkflowTas
k

A3

Respons
e

ActivityTaskStarted A2
ActivityTaskTimedOut A2
WorkflowTaskScheduled

Start

A1

A2 (2)

A3

Close

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Schedule A2 (2)

History

ActivityTaskStarted A2
ActivityTaskTimedOut A2

ActivityTaskScheduled
A2

Start

A1

A2 (2)

A3

Close

History
SimpleWorkfl
ow

PollForActivityTa
sk

Respons
e

A2

ActivityTaskStarted A2
ActivityTaskTimedOut A2

ActivityTaskScheduled
A2
ActivityTaskStarted A2

Start

A1

A2 (2)

A3

Close

Result
SimpleWorkfl
ow

RespondActivityTaskCompl
eted

Datum_1 = FOO

History

A2

ActivityTaskStarted A2
ActivityTaskCompleted
A2
WorkflowTaskScheduled

Start

A1

History

ActivityTaskStarted A2
ActivityTaskTimedOut A2

ActivityTaskScheduled A2
ActivityTaskStarted A2
ActivityTaskCompleted A2
WorkflowTaskScheduled

A2 (2)

A3

Decisions
Schedule A3

Close

Exclusive Choice with Simple


Merge

Exclusive Choice with Simple


Merge
A4

a
Start

A1

A2

A3

Close

Choose one step (or set of steps) over another


Choice can be based on results of activity execution
Alternative path merged back with normal control flow
at later point
Simple example entails handling of a failure condition
Also cover Data-based Routing pattern
SWF features supporting these patterns:
Explicit failure notification
Data passing and persistence

A4
Start

A1

A2

Respons
e

A2

Close

History

SimpleWorkfl
ow

PollForActivityTa
sk

A3

ActivityTaskScheduled
A2
ActivityTaskStarted A2

A4
Start

A1

A2

A3

Close

Result
SimpleWorkfl
ow

RespondActivityTaskFail
ed

FAULT_DETAILS = FOO

History

ActivityTaskStarted A2
ActivityTaskFailed A2
WorkflowTaskScheduled
A2

A4
Start

A1

A2

Close

History

SimpleWorkfl
ow

PollForWorkflowTas
k

A3

Respons
e

ActivityTaskStarted A2
ActivityTaskFailed A2
WorkflowTaskScheduled

A4
Start

A1

A2

A3

Close

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Schedule A4

History

ActivityTaskStarted A2
ActivityTaskFailed A2

ActivityTaskScheduled
A4

Parallel Split with


Synchronization

Parallel Split with


Synchronization
A1
Start

A3

Close

A2

Execute two or more steps (or sequences of


steps) at once
Continue forward with only one branch once
parallel activities are done
Also cover Scoped Data
SWF features supporting these patterns:
Recording split/join
Scheduling with split/join
Branch-scoped data

A1
Start

A3

Close

A2

History

SimpleWorkfl
ow

PollForWorkflowTas
k

WorkflowInstanceStarted
WorkflowTaskScheduled
Respons
e

A1
Start

A3

Close

A2

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Record Split
Schedule A1
Schedule A2

History

WorkflowTaskCompleted
SplitRecorded
ActivityTaskScheduled A1
ActivityTaskScheduled A2

A1
Start

A3

Close

A2

History

SimpleWorkfl
ow

PollForActivityTa
sk

Respons
e

A1

SplitRecorded
ActivityTaskScheduled A1
ActivityTaskScheduled A2
ActivityTaskStarted A1

A1
Start

A3

Close

A2

History

SimpleWorkfl
ow

PollForActivityTa
sk

Respons
e

A2

ActivityTaskScheduled A1
ActivityTaskScheduled A2
ActivityTaskStarted A1
ActivityTaskStarted A2

A1
Start

A3

Close

A2

Result
SimpleWorkfl
ow

RespondActivityTaskCompl
eted

Datum_1 = FOO

History

A1

ActivityTaskStarted A1
ActivityTaskCompleted
A1
WorkflowTaskScheduled

A1
Start

A3

Close

A2

History

SimpleWorkfl
ow

PollForWorkflowTas
k

Respons
e

ActivityTaskScheduled A1
ActivityTaskScheduled A2
ActivityTaskStarted A1
ActivityTaskStarted A2
ActivityTaskCompleted A1
WorkflowTaskScheduled

A1
Start

A3

Close

A2

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

History

ActivityTaskStarted A1
ActivityTaskStarted A2
ActivityTaskCompleted A1
WorkflowTaskScheduled
WorkflowTaskStarted
WorkflowTaskCompleted

A1
Start

A3

Close

A2

Result
SimpleWorkfl
ow

RespondActivityTaskCompl
eted

Datum_1 = BAR

History

A2

ActivityTaskStarted A2

ActivityTaskCompleted A2
WorkflowTaskScheduled

A1
Start

A3

Close

A2

History

SimpleWorkfl
ow

PollForWorkflowTas
k

Respons
e

ActivityTaskCompleted A1

ActivityTaskCompleted A2
WorkflowTaskScheduled

A1
Start

A3

Close

A2

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Record Join
Schedule A3

History

ActivityTaskCompleted A1

ActivityTaskCompleted A2

WorkflowTaskCompleted
JoinRecorded
ActivityTaskScheduled A3

Persistent Trigger

Persistent Trigger
Start

A1

Wait

A2

Close

Trigger from external process affecting the


workflow execution
Triggers come in the form of signals
Workflow can wait for a period of time for signal
Also cover Event-based Task Trigger
SWF features supporting these patterns:

Signal workflow
Complete signal
Schedule activity with delay
Cancel activity

Start

A1

Wait

Close

History

SimpleWorkfl
ow

PollForWorkflowTas
k

A2

Respons
e

ActivityTaskStarted A1
ActivityTaskCompleted A1
WorkflowTaskScheduled

Start

A1

Wait

A2

Close

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Schedule Wait (Empty, Delayed)

History

WorkflowTaskCompleted
ActivityTaskScheduled
Wait

Start

A1

SimpleWorkfl
ow

SignalWorkflowInsta
nce

Wait

A2

Close

History

ActivityTaskScheduled
Wait
SignalRecorded
WorkflowTaskScheduled

Start

A1

Wait

Close

History

SimpleWorkfl
ow

PollForWorkflowTas
k

A2

Respons
e

ActivityTaskScheduled Wait
SignalRecorded
WorkflowTaskScheduled

Start

A1

Wait

A2

Close

Decisions
SimpleWorkfl
ow

RespondWorkflowTaskCom
pleted

Complete Signal
Cancel Wait
Schedule A2

History

WorkflowTaskCompleted
SignalClosed
ActivityTaskCancelTried
Wait
ActivityTaskCanceled Wait
ActivityTaskScheduled A2

Start

A1

History

ActivityTaskStarted Wait
ActivityTaskCompleted
Wait
WorkflowTaskScheduled

Wait

A2

Close

Decisions

Many more
Multi-Choice
Workflow Data

Interleaved Parallel Routing

Direct Distribution

Suspension-Resumption

Cancelling Discriminator
Cancel Region

Explicit Termination

Data Interaction - to Multiple Instance Task

Blocking Partial Join

Selection Autonomy

Capability-Based Distribution
Multiple Instances with a Priori Run-Time
Knowledge
Task Postcondition - Data Existence

Decider Framework
Provides direct support for many
patterns
Build workflows by composing
scoped deciders
Simple set of components combine
to express complex workflows

Composing Deciders
Workflow
Sequence
Split/Join
Activity
A1

Start

A1
A2
Activity

A2

A3

Activity

A3

Close

Provided Decider
Implementations
WorkflowDecider closes/fails workflow and input/result
ActivityDecider controls single activity execution and
retries
SequenceDecider sequence of deciders
SwitchDecider one of the set based on condition
SplitJoinDecider parallel execution of deciders
WhileDecider loop with precondition
DoWhileDecider loop with postcondition
TryCatchFinallyDecider exception based error handling
WaitForSignalDecider blocks execution until signal
received
DelayDecider delays execution of a decider
RetryDecider retries execution of a decider in case of
failures
ConditionDecider conditionally executes a decider

Links
Patterns:
www.workflowpatterns.com

Wiki:
w.amazon.com/?SWF

Email:
[email protected]
[email protected]
[email protected]

Contact-us

Takeaways
Steps to build and execute workflows
using SimpleWorkflow
Workflow patterns are useful
conceptual design tools
SimpleWorkflow has the capabilities
necessary to express many workflow
patterns
Frameworks are available to make your
job easier

Thanks!
SWF Team

Rodrigo De Castro
Drew Gochenaur
Maxim Fateev
Jacques Thomas
Andy Kotlinski
Fatih Boyaci
Pat Maguire
Srikanth Satyanarayana

POA Talk Advisors


Users

You might also like