Amazon SWF is a web service that manages the coordination of workflows across distributed systems which can involve any number of activities to help build scalable and resilient applications. It enables the coordination of activities and its execution across multiple computing devices and across different AWS regions. These workflows can be carried out sequentially or in parallel. This article, Amazon Simple Workflow Services – SWF Exam Tips provides some key points you should be aware of before entering the exam room.
Amazon SWF will maintain individual execution states to enable the seamless flow of activities and this can also involve human interaction as a component that performs set tasks to help complete the workflow process for a given application.
A series of tasks represent a workflow which can spread across different distributed systems and be coordinated in a manner to ensure that the customer receives the products they ordered. In addition, key points to note include:
- Activities within a workflow can run sequentially, in parallel, synchronously and asynchronously
- Activities can be carried out in different locations
- Programmatic tasks can be written in different programming languages
Each workflow has a workflow history which records every event that occurred since the workflow started. Each event represents a change in the workflow execution state identifying scheduled or completed activities or tasks that may have passed or failed for example due to a timeout. Note that the workflow history only shows events that have changed the state of the workflow executions. Poll attempts, for example, are not recorded in the history.
Workflow History benefits include:
- Applications can be stateless as the workflow history stores all information about the workflow execution states
- For every execution, the history will store information such as which activities have been scheduled, their current state and the results
- You can use the history as an audit trail to monitor executions and verify complete or incomplete status
Amazon SWF Actors
There are three programmatic ‘actors’ that Amazon SWF interacts with to carry out workflows. Actors communicate with Amazon SWF using APIs, which can be developed in any language
Workflow Starters are applications that initiate workflow executions. This can be the website for an eCommerce store or a Map Application on a Mobile App to give directions.
Amazon SWF will monitor the progress of a workflow execution and state change. At each state change, Amazon SWF creates a decision task that contains the history up to the point of change and assigns it to a Decider. The Decider analyses the execution history and determines the next step to be taken by an Activity Worker. Amazon SWF then instructs an Activity Worker and the process continues until the Decider determines that the execution has completed. The Decider then informs Amazon SWF with a decision to close the execution.
Activity workers are processes that perform tasks identified in each application. Activity workers will poll Amazon SWF for new tasks appropriate for that worker to perform. Once it receives a task, it will process the task to completion and report the result to Amazon SWF. The worker then polls for a new task.
Activity workers can be independent processes and applications, for example. the credit card process, or the warehouse employee’s job sheet instructing the employee to package a product for delivery.
Amazon SWF interacts with its Actors as discussed above by assigning them with tasks. There are three types of tasks:\
- Activity Task
- Lambda Task
- Decision Tasks
Task Lists enable you to organise Amazon SWF workflow tasks and better manage them. You need to specify a task list that will host specific tasks when you schedule it. A task list can be thought of as a dynamic queue from which you poll Amazon SWF for a task.
These lists enable you to route tasks to active workers and deciders and do not need to be registered. You can either use the default task list or create specific tasks list at run time. In addition, the following key points should be noted about task lists:
- Separate lists need to be used for activity tasks and decision tasks
- Tasks can only be scheduled on a single task list
- Tasks are not shared across lists
- Task lists need to be scoped to a specific AWS region and SWF domain
- Task List can help in ensuring that workers and deciders get only those tasks which you want to assign them or which they can perform.
Workflow Execution Closure
When workflow executions start, they identified as in an ‘Open’ state. Open Workflows can be closed in the following states:
Workflow Executions can be closed by either the decider, the person administering the workflow or Amazon SWF.
Deciders and activity workers poll Amazon SWF for tasks using a process called long polling. Should a task not be immediately available, Amazon SWF will hold the TCP connection for 60 seconds in case a new task becomes available. This one-minute duration where Amazon SWF keeps the connection open ensures a reduction in the number of polls that are returned without any tasks and thereby reduces the inefficiencies associated with polling.
Amazon SWF vs. Amazon SQS
The following are key differences between Amazon SWF and Amazon SQS which you should be aware:
- Amazon SQS has a retention period of 14 days, SWF can take up to 1 Year
- Amazon SWF presents tasks oriented APIs, whereas Amazon SQS offers message oriented APIs
- Amazon SWF ensures the task is assigned only once and is never duplicated. With Amazon SQS, you can end up with duplicate messages (when using standard queues), and you need to have a process to handle these. The alternative is to use the new Amazon SQS First-In-First-Out (FIFO) queues. Check out our article, Amazon SQS – Certified Solutions Architect Exam Key Notes for more details.
- Amazon SWF keeps track of all tasks and events in an application. With Amazon SQS, you need to implemented you own application-level tracking if you are using multiple queues
Additional Exam Tips
- Amazon SWF can be accessed and interacted with in the following ways:
- AWS SDK for Java, Ruby, NET, and PHP
- AWS Flow Framework for Java (Included in the AWS SDK for Java)
- Amazon SWF web service APIs
- AWS Management Console
- Workflow Executions can be associated with an ExecutionID which Amazon SWF uses to ensure that only one execution runs at a given time and prevents attempts to start additional executions with the same ID. Typical use-case includes ensuring that a user can click a submit button only once while registering on a website. This prevents multiple registrations happening and further attempts to click the submit button are ignored.
- In cases where multiple executions need to use the same ExecutionID, Amazon SWF will differentiate by using an associated RunID which will always be unique
- Amazon SWF is scalable and you can use run-time data provided by Amazon SWF to determine triggers for scaling up or down
- The Amazon SWF Management Console can be used to monitor the state of executions and allow you to take appropriate actions
- You can grant IAM user permissions to access Amazon SWF and you need to specify which domains and APIs your IAM users can access
- Amazon SWF workers can operate behind firewalls and you do not have to configure specific inbound rules as your workers initiate requests to Amazon SWF. This is true where the firewall is Stateful
- You can have a maximum total of 10,000 workflows and activity type registered in each domain
- At any point in time, you can have a maximum of 100,000 open executions in a domain
- Each workflow execution can run for a maximum of 1 year
- Workflow execution history can grow up to 25,000 events. To store additional events, you can use create new child workflow executions
- A maximum of 100 activity tasks can be scheduled in a single decision and these decisions can be issued one after another
- A maximum of 1,000 open activity tasks can exist per workflow execution, as can 1,000 open timers and up to 1,000 open child executions
- Amazon SWF APIs impose a maximum of 32,000 characters as data that can be passed within an execution
- Amazon SWF can store a history of completed executions for up to 90 Days
- Amazon SWF may throttle your API calls if your applications are experiencing spikes in very short period
- For High Availability, Amazon SWF manages your execution history and workflow details across 3 availability zone
180 Practice Exam Questions – Get Prepared for your Exam Day!
Our Exam Simulator with 180 practice exam questions comes with comprehensive explanations that will help you prepare for one of the most sought-after IT Certifications of the year. Register Today and start preparing for your AWS Certified Solutions Architect – Associate Exam.