• by

AWS SWF – Simple Workflow

AWS Simple Workflow Concept

Amazon Simple Workflow Service (Amazon SWF) is a workflow service for building scalable, resilient applications. It is a task based API that makes it easy to coordinate work across distributed application components.

It provides a programming model and infrastructure for coordinating distributed components and maintaining their execution state in a reliable way.

AWS Simple Workflow | Start Learning Online
  • Workflow
    • Fundamental concept in SWF is the Workflow, which is the automation of a business process.
    • A workflow is a set of activities that carry out some objective, including logic that coordinates the activities to achieve the desired output.
  • Workflow execution
    • Running state of any workflow.
  • Workflow history
    • It consists of complete and consistent record aka audit trail of each event that occurred since the workflow execution started.
    • It enables applications to be stateless as all information about a workflow execution is stored in its workflow history.
    • Polling execution do not typically appear in the workflow history as it does not change the state of the workflow.
    • Markers can be used to record information in the workflow history of a workflow execution that is specific to the use case.
  • Actors
    • Amazon SWF interacts with a number of different types of programmatic actors. Actors can be a workflow starters, deciders, or activity workers. These actors communicate with Amazon SWF through its API.
  • Domain
    • Each and every workflow runs in an AWS resource called a Domain, which controls the scope of any workflow.
    • An AWS Account can have multiple domains.
    • The workflow defined in a domain can not interact with other workflow defined in another domain.
  • Tasks
    • SWF interacts with activity workers and deciders by providing them work assignments known as tasks.
    • There are three types of tasks in Amazon SWF
      • Activity task
        • An Activity task tells an activity worker to perform its function. An Activity Worker performs them, and provides results back. An activity worker can be a program or even a person who performs the task using an activity worker software.
        • run synchronously or asynchronously, can be distributed across multiple computers, potentially in different geographic regions, or run on the same computer.
        • It can be written in different programming languages and run on different operating systems.
        • It can be created that are long-running, or that may fail, time out require restarts or that may complete with varying throughput & latency.
      • Lambda task
        • A Lambda task is similar to an Activity task, but executes a Lambda function instead of a traditional Amazon 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.
  • Decider
    • It implements a Workflow’s coordination logic
    • Decider schedules activity tasks, provides input data to the activity workers, processes events that arrive while the workflow is in progress, and ends (or closes) the workflow when the objective has been completed.
    • Decider directs the workflow by receiving decision tasks from SWF and responding back to SWF with decisions. A decision represents an action or set of actions which are the next steps in the workflow which can either be to schedule an activity task, set timers to delay the execution of an activity task, to request cancellation of activity tasks already in progress, and to complete or close the workflow.
  • Workers and Deciders are both stateless, and can respond to increased traffic by simply adding additional Workers and Deciders as needed.
  • The relationship between the different constructs related to workflows and deciders is shown below:
  • Role of SWF service is to function as a reliable central hub through which data is exchanged between the decider, the activity workers, and other relevant entities such as the person administering the workflow.
  • Mechanism by which both the activity workers and the decider receive their tasks (activity tasks and decision tasks resp.) is by polling the SWF
  • SWF allows “long polling”, requests will be held open for up to 60 seconds if necessary, to reduce network traffic and unnecessary processing
  • AWS SWF informs the decider of the state of the workflow by including with each decision task, a copy of the current 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 for e.g events would be the completion of a task, notification that a task has timed out, or the expiration of a timer that was set earlier in the workflow execution. The history is a complete, consistent, and authoritative record of the workflow’s progress

Workflow Implementation & Execution

  1. Implement Activity workers with the processing steps in the Workflow.
  2. Implement Decider with the coordination logic of the Workflow.
  3. Register the Activities and workflow with AWS SWF.
  4. Start the Activity workers and Decider. Once started, the decider and activity workers should start polling AWS SWF for tasks.
  5. Start one or more executions of the Workflow. Each execution runs independently and can be provided with its own set of input data.
  6. When an execution is started, SWF schedules the initial decision task. In response, the decider begins generating decisions which initiate activity tasks. Execution continues until your decider makes a decision to close the execution.
  7. View and Track workflow executions

AWS Certification Exam | Practice Questions for AWS SWF

The questions are collected from Internet. The answers are based on my experience. Please apply your idea before you select any answer.

What does Amazon SWF stand for?

A. Simple Web Flow
B. Simple Work Flow
C. Simple Wireless Forms
D. Simple Web Form

Regarding Amazon SWF, the coordination logic in a workflow is contained in a software program called a __.

A. Handler
B. Decider
C. Coordinator
D. Worker

Reading Reference for AWS Certification

Developer’s guide

If you find this article useful, feel free to share and give a like. Your feedback is our inspiration. To read more such article, please click here.

Amazon Kinesis AMI Automation AWS AWS AppStream 2.0 AWS Backup aws certifications aws certifications catalog AWS EBS AWS Elastic Transcoder AWS IAM AWS Sagemaker aws services AWS SES aws support aws swf AWS WorkSpaces AWS X-Ray Azure Cost Management Best Practices chage command Linux Cloud Computing Cloud Migration Data Science DNS Edge Computing Fog Computing Interview Preparation Jenkins Kubernetes Linux Linux User Management Microsoft Azure OSI Model Python R sample questions Server Hardening Supercomputer WordPress