AWS Simple Workflow Service (Amazon SWF)學習筆記

Amazon SWF makes it easy to build applications that coordinate work across distributed
components.

When using Amazon SWF, you implement workers to perform tasks.These workers can run either on cloud infrastructure, such as Amazon EC2, or on your own premises.

Workflows

Using Amazon SWF, you can implement distributed, asynchronous applications as
workflows.

Workflow Domains

Domains provide a way of scoping Amazon SWF resources within your AWS account.

Workflow History

The workflow history is a detailed, complete, and consistent record of every event that
occurred since the workflow execution started.

Actors

Amazon SWF consists of a number of different types of programmatic features known as actors.Actors can be workflow starters, deciders, or activity workers.
A workflow starter is any application that can initiate workflow executions.
Activities within a workflow can run sequentially, in parallel, synchronously, or
asynchronously.
The logic that coordinates the tasks in a workflow is called the decider.The
decider schedules the activity tasks and provides input data to the activity workers.
An activity worker is a single computer process (or thread) that performs the activity tasks in your workflow.

Tasks

Amazon SWF provides activity workers and deciders with work assignments, given as one of three types of tasks: activity tasks, AWS Lambda tasks, and decision tasks.
Each decision task contains a paginated view of the entire workflow execution history.

Long Polling

Deciders and activity workers communicate with Amazon SWF using long polling.

Lifecycle of a Workflow Execution

在這裏插入圖片描述
Amazon SWF workflow illustration

  1. A workflow starter calls an Amazon SWF action to start the workflow execution for an order, providing order information.
  2. Amazon SWF receives the start workflow execution request and then schedules the first decision task.
  3. The decider receives the task from Amazon SWF, reviews the history, and applies the coordination logic to determine that no previous activities occurred. It then makes a decision to schedule the Verify Order activity with the information the activity worker needs to process the task and returns the decision to Amazon SWF.
  4. Amazon SWF receives the decision, schedules the Verify Order activity task, and waits for the activity task to complete or time out.
  5. An activity worker that can perform the Verify Order activity receives the task, performs it, and returns the results to Amazon SWF.
  6. Amazon SWF receives the results of the Verify Order activity, adds them to the workflow history, and schedules a decision task.
  7. The decider receives the task from Amazon SWF, reviews the history, applies the
    coordination logic, makes a decision to schedule a Charge Credit Card activity task with information the activity worker needs to process the task, and returns the decision to Amazon SWF.
  8. Amazon SWF receives the decision, schedules the Charge Credit Card activity task, and waits for it to complete or time out.
  9. An activity worker activity receives the Charge Credit Card task, performs it, and returns the results to Amazon SWF.
  10. Amazon SWF receives the results of the Charge Credit Card activity task, adds them to the workflow history, and schedules a decision task.
  11. The decider receives the task from Amazon SWF, reviews the history, applies the
    coordination logic, makes a decision to schedule a Ship Order activity task with the information the activity worker needs to perform the task, and returns the decision to Amazon SWF.
  12. Amazon SWF receives the decision, schedules a Ship Order activity task, and waits for it to complete or time out.
  13. An activity worker that can perform the Ship Order activity receives the task, performs it, and returns the results to Amazon SWF.
  14. Amazon SWF receives the results of the Ship Order activity task, adds them to the
    workflow history, and schedules a decision task.
  15. The decider receives the task from Amazon SWF, reviews the history, applies the coordination logic, makes a decision to schedule a Record Completion activity task with
    the information the activity worker needs, performs the task, and returns the decision to
    Amazon SWF.
  16. Amazon SWF receives the decision, schedules a Record Completion activity task, and waits for it to complete or time out.
  17. An activity worker Record Completion receives the task, performs it, and returns the results to Amazon SWF.
  18. Amazon SWF receives the results of the Record Completion activity task, adds them to the workflow history, and schedules a decision task.
  19. The decider receives the task from Amazon SWF, reviews the history, applies the
    coordination logic, makes a decision to close the workflow execution, and returns the decision along with any results to Amazon SWF.
  20. Amazon SWF closes the workflow execution and archives the history for future
    reference.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章