Home » AWS SWF | Simple Workflow Service

AWS SWF | Simple Workflow Service

by Online Tutorials Library

What is SWF?

  • SWF stands for Simple Workflow Service.
  • It is a web service used to build scalable and resilient applications.
  • It provides simple API calls which can be executed from code written in any language and can be run on your EC2 instance or any of your machines located anywhere in the world that access the internet. For example, you are building an application which consists of various modules, and to coordinate among various modules; we rely on SWF in aws. SWF acts as a coordinator, and it has control over all the modules of an application.
  • It allows you to build applications and makes it easy to coordinate the work across distributed components.
  • SWF provides a logical separation among all the components of a project.
  • SWF involves in coordinating various tasks such as managing inter-task dependencies, scheduling, and concurrency in accordance with the logical flow of the application. You do not have to manage the tasks manually; SWF will do everything for you.

Let’s understand through an example.

SWF

Suppose customer placed an order.

Step 1: You have to verify an order. You have your EC2 instances, and they go and check whether the order is in stock or not. Once the order has been verified, i.e., you have got a stock, then move to step 2.

Step 2: Now, it works on the Charge Credit card. It checks whether the charge of a credit card has been successful or not.

Step 3: If the charge of a credit card has been successful, we will ship an order. Shipping an order needs human interaction. Human brings order from the warehouse, and if the product has been boxed up means that it is ready for the shipment.

Step 4: Record Completion is a database which says that the product has been boxed up and shipped to the destination address. It also provides the tracking number. This is the end of the typical workflow.

SWF Workers and Deciders

  • Workers are the programs that interact with the Amazon SWF to get the tasks, process the received tasks, and return the results.
  • The decider is a program that provides coordination of tasks such as ordering, concurrency, scheduling, etc according to the application logic.
  • Both workers and deciders run on the cloud infrastructure such as Amazon EC2, or machines behind firewalls.
  • Deciders take a consistent view into the progress of tasks and initiate new tasks while Amazon SWF stores the tasks and assigns them to the workers to process them.
  • Amazon SWF ensures that the task is assigned only once and is never duplicated.
  • Workers and Deciders do not have to keep track of the execution state as Amazon SWF maintains the state durably.
  • Both the workers and deciders run independently and scale quickly.

SWF Domains

  • Domains are containers which isolate a set of types, executions, and task lists from others within the same account.
  • Workflow, activity types, and workflow execution are all scoped to a domain.
  • You can register a domain either by using the AWS Management Console or RegisterDomain action in the Amazon SWF API.

The parameters are specified in a JSON (Javascript Object Notation) format. The format is shown below:

Where,

workflowExecutionRetentionPeriodInDays defines the number of days of retention period.

Note: The maximum workflow can be 1 year and its value is measured in seconds.

Differences b/w SQS and SWF

  • Amazon SWF provides a task-oriented API while Amazon SQS provides a message-oriented API./li>
  • Amazon SWF ensures that the task is assigned only once and is never duplicated. With Amazon SQS, the message can be duplicated and it may also need to ensure that a message is processed only once./li>
  • SWF keeps track of all tasks and events in an application while SQS implements its own application level tracking when an application uses multiple queues.

Features of SWF

SWF

  • Scalable
    Amazon SWF automatically scales the resources along with your application’s usage. There is no manual administration of the workflow service required when you add more cloud workflows or increase the complexity of the workflows.
  • Reliable
    Amazon SWF runs at Amazon’s highly available data centres, therefore the state tracking is provided whenever applications need them. Amazon SWF stores the tasks, sends them to their respective application components, keeps a track on their progress.
  • Simple
    Amazon SWF completely replaces the complexity of the old workflow solutions and process automation software with new cloud workflow internet service. It eliminates the need for the developers to manage the automation process so that you can focus on the unique functionality of an application.
  • Logical separation
    Amazon SWF provides a logical separation between the control flow of your background job’s stepwise logic and the actual units of work that contains business logic. Due to the logical separation, you can separately manage, maintain, and scale “state machinery” of your application from the business logic. According to the change in the business requirements, you can easily manage the business logic without having worry about the state machinery, task dispatch, and flow control.
  • Flexible
    Amazon SWF allows you to modify the application components, i.e., you can modify the application logic in any programming language and runs them within the cloud or on-premises.

Next TopicSNS

You may also like