Amazon Simple WorkFlow (Amazon SWF)
- A fully-managed state tracker and task coordinator in the Cloud. You create desired workflows with their associated tasks and any conditional logic you wish to apply and store them with SWF.
- SWF promotes a separation between the control flow of your background job’s stepwise logic and the actual units of work that contain your unique business logic.
- SWF manages your workflow execution history and other details of your workflows across 3 availability zones.
- SWF lets you write your application components and coordination logic in any programming language and run them in the cloud or on-premises.
- SWF is highly scalable. It gives you full control over the number of workers that you run for each activity type and the number of instances that you run for a decider.
- SWF also provides the AWS Flow Framework to help developers use asynchronous programming in the development of their applications.
- A set of activities that carry out some objective, together with logic that coordinates the activities.
- Workflows coordinate and manage the execution of activities that can be run asynchronously across multiple computing devices and that can feature both sequential and parallel processing.
- Each workflow runs in an AWS resource called a domain, which controls the workflow’s scope.
- An AWS account can have multiple domains, each of which can contain multiple workflows, but workflows in different domains can’t interact.
- When you register an activity to a workflow, you provide information such as a name and version, and some timeout values based on how long you expect the activity to take.
- Activity Task
- An activity task tells an activity worker to perform its function.
- SWF stores tasks and assigns them to workers when they are ready, tracks their progress, and maintains their state, including details on their completion.
- To coordinate tasks, you write a program that gets the latest state of each task from SWF and uses it to initiate subsequent tasks.
- Activity tasks can run synchronously or asynchronously. They can be distributed across multiple computers, potentially in different geographic regions, or they can all run on the same computer.
- Activity tasks for a running workflow execution appear on the activity task list, which is provided when you schedule an activity in the workflow.
- If you don’t specify a task list when scheduling an activity task, the task is automatically placed on the default task list.
- Lambda task
- Executes a Lambda function instead of a traditional SWF activity.
- Decision task
- A Decision task tells a decider that the state of the workflow execution has changed so that the decider can determine the next activity that needs to be performed. The decision task contains the current workflow history.
- SWF assigns each decision task to exactly one decider and allows only one decision task at a time to be active in a workflow execution.
- Workflow Starter
- Any application that can initiate workflow executions.
- Activity Worker
- An activity worker is a program that receives activity tasks, performs them, and provides results back.
- Implement workers to perform tasks. These workers can run either on cloud infrastructure, or on your own premises.
- Different activity workers can be written in different programming languages and run on different operating systems.
- Assigning particular tasks to particular activity workers is called task routing. Task routing is optional.
- A software program that contains the coordination logic in a workflow.
- It schedules activity tasks, provides input data to the activity workers, processes events that arrive while the workflow is in progress, and ultimately ends the workflow when the objective has been completed.
- Both activity workers and the decider receive their tasks by polling the SWF service.
- Workflow Execution History
- The workflow execution history is composed of events, where an event represents a significant change in the state of the workflow execution.
- SWF informs the decider of the state of the workflow by including, with each decision task, a copy of the current workflow execution history.
- Deciders and activity workers communicate with SWF using long polling.
- Write activity workers that implement the processing steps in your workflow.
- Write a decider to implement the coordination logic of your workflow.
- Register your activities and workflow with Amazon SWF.
- Start your activity workers and decider.
- Start one or more executions of your workflow. Each execution runs independently and you can provide each with its own set of input data. When an execution is started, Amazon SWF schedules the initial decision task. In response, your decider begins generating decisions which initiate activity tasks. Execution continues until your decider makes a decision to close the execution.
- Filter and view complete details of running as well as completed executions.
SWF provides service operations that are accessible through HTTP requests.
- To reduce latency and to store data in a location that meets your requirements, SWF provides endpoints in different regions.
- Each endpoint is completely independent. When you register an SWF domain, workflow or activity, it exists only within the region you registered it in.
AWS Flow Framework
- An enhanced SDK for writing distributed, asynchronous programs that can run as workflows on SWF.
- It is available for the Java and Ruby programming languages, and it provides classes that simplify writing complex distributed programs.
- You pay for workflow executions when you start them and for each 24-hour period until they are completed. The first 24 hours of workflow execution are free.
- You pay for “markers” (custom workflow execution log entries), start timers, or receive signals of additional tasks generated from a workflow.
- Data transferred between SWF and other AWS services within a single region is free of charge. Data transferred between SWF and other AWS services in different regions will be charged at Internet Data Transfer rates on both sides of the transfer. First 1 GB of transferred data is free.
SQS vs SWF
- SQS offers reliable, highly-scalable hosted queues for storing messages while they travel between applications or microservices.
- SWF is a web service that makes it easy to coordinate work across distributed application components.
- SWF API actions are task-oriented. SQS API actions are message-oriented.
- SWF keeps track of all tasks and events in an application. SQS requires you to implement your own application-level tracking.
- SWF offers several features that facilitate application development, such as passing data between tasks, signaling, and flexibility in distributing tasks.
- Maximum registered domains – 100
- Maximum workflow and activity types – 10,000 each per domain
- Maximum open workflow executions – 100,000 per domain
- Maximum open activity tasks – 1,000 per workflow execution
- Maximum workflow execution time – 1 year
- Each workflow execution history can grow up to 25,000 events
- Maximum task execution time – 1 year
- Schedule up to 100 activity tasks in one decision
- Maximum execution history retention is 90 days.
AWS Certified Solutions Architect is consistently among the top paying IT certifications in the world, considering that Amazon Web Services is the leading cloud services platform with almost 50% market share! Earn over $150,000 per year with an AWS certification!
Subscribe to our newsletter for more helpful AWS training notes and blogs like this and answer as many AWS practice exams as you can. 🙂