8.2 SWF - Simple Workflow Service
What is SWF
Amazon Simple Workflow Service (Amazon SWF) is a web service that makes it easy to coordinate work across distributed application components. Amazon SWF enables applications for a range of use cases, including media processing, web application back-ends, order/business process workflows, and analytics pipelines, to be designed as a coordination of tasks. Tasks represent invocations of various processing steps in an application which can be performed by executable code, web service calls, human-being actions, and scripts (doesn't have to involve EC2 instances or AWS related services).
Uses cases on AWS Docs:
Video encoding using Amazon S3 and Amazon EC2.
Migrating components from the datacenter to the cloud.
Processing large product catalogs with human works using Amazon Mechanical Turk.
SWF vs. SQS
SQS has retention period of 14 days, SWF up to 1 year for workflow executions.
Amazon SWF presents a task-oriented API, whereas Amazon SQS offers a message-oriented API.
Amazon SWF ensures that a task is assigned/processed only once is never duplicated. With Amazon SQS, you need to handle duplicated messages and may also need to ensure that a message is processed only once.
Amazon SWF keeps track of all the tasks and events in an application. With Amazon SQS, you need to implement your own application-level tracking, especially if your application uses multiple queues.
SWF Actors
You must remember these 3 kinds of actors:
Workflow Starters - An application that can initiate (start) a workflow. Could be your e-commerce website when placing an order or a mobile app searching for bus times.
Deciders - Control the flow of activity tasks in a workflow execution. If something has finished in a workflow (or fails) a Decider decides what to do next.
Amazon SWF maintains the workflow execution history and provides it to a decider along with decision task. This enables you to dynamically add or remove deciders as necessary, which makes the processing of your workflows highly scalable.
Every time a state change occurs for a workflow execution, Amazon SWF schedules a decision task. Each time a decider receives a decision task, it does the following:
Interprets the workflow execution history provided with the decision task.
Applies the coordination logic based on the workflow execution history and makes decisions on what to do next.
Completes the decision task and provides a list of decisions to Amazon SWF.
Activity Workers - Carry out the activity tasks.
Last updated
Was this helpful?