Aws dc simple-workflow

1,361 views
1,198 views

Published on

My preso on SimpleWorkFlow from the AWS-DC meetup

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,361
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Aws dc simple-workflow

  1. 1. AWSSimple WorkFlow by Nathan McCourtney May 2nd, 2012 @beaknit
  2. 2. "Workflow"?A workflow management system is a computer system thatmanages and defines a series of tasks within anorganization to produce a final outcome or outcomes.At each stage in the workflow, one individual or group isresponsible for a specific task. Once the task is complete,the workflow software ensures that the individualsresponsible for the next task are notified and receive thedata they need to execute their stage of the processhttp://en.wikipedia.org/wiki/Workflow
  3. 3. Amazons Workflow Model● A Workflow is the automation of a business process.● A Domain is a collection of related Workflows.● Actions are the individual tasks undertaken to carry out a Workflow.● Activity Workers are the pieces of code that actually implement the tasks. Each kind of Worker has its own Activity Type.● A Decider implements a Workflows coordination logic.- From Jeff Barrs post
  4. 4. Workers & Deciders = ActorsFrom wikipedia:In computer science, the Actor model is a mathematicalmodel of concurrent computation that treats "actors" as theuniversal primitives of concurrent digital computation: inresponse to a message that it receives, an actor can makelocal decisions, create more actors, send more messages,and determine how to respond to the next messagereceived.
  5. 5. Essentially, SWF is a framework for abstracting out actors and passingmessages between them via queues
  6. 6. Act! Work Queue Actor Messages1. Fetches its work2. Drops off its results Result Queue
  7. 7. AWS Message Passing ● HTTPS ● Long-poll interval of 60 seconds ● Message format is JSON: {"decisionType": "ScheduleActivityTask", "scheduleActivityTaskDecisionAttributes": {"activityType": {"name": "activityVerify", "version": "1.0"}, "activityId": "verification-27", "control": "digital music", "input": "5634-0056-4367-0923,12/12,437", "scheduleToCloseTimeout": "900", "taskList": {"name": "specialTaskList"}, "scheduleToStartTimeout": "300", "startToCloseTimeout": "600", "heartbeatTimeout": "120"} } ● One decision queue per Workflow ● Many activity queues per Workflow
  8. 8. Decider to SWF Comms SWF Decider DTL ATL 1. Decider polls Decision Task List (DTL) for new decision tasks 2. Decision task returned with entire workflow execution history to provider context for decisions 3. Decider executes conditional logic and returns an activity task back to SimpleWorkFlow which then deposits in the Activity Task List (ATL)Note: Multiple deciders can process the same DTL
  9. 9. From AWS Ruby SDK# poll for decision tasks from my-task-list domain.decision_tasks.poll( my-task-list ) do |task| # investigate new events and make decisions task.new_events.each do |event| case event.event_type when WorkflowExecutionStarted task.schedule_activity_task do-something , :input => abc xyz when ActivityTaskCompleted task.complete_workflow_execution :result => event.attributes.result end end end # decision task is completed here
  10. 10. Worker to SWF Comms SWF Worker ATL DTL 1. Worker polls ATL for appropriate tasks - different workers can consume different tasks 2. Task completion returned to SWF which makes the result available to the Decider via the DTL Note: Multiple workers can process the same ATL
  11. 11. From AWS Ruby SDK# poll my-task-list for activities domain.activity_tasks.poll( my-task-list ) do |activity_task| case activity_task.activity_type.name when do-something # ... else activity_task.fail! :reason => unknown activity task type end end
  12. 12. AWS example order-processing SWF Source: SWF Dev Guide
  13. 13. Practical ExerciseNightly restore of a database to QA nodes combined with automated releasemigration.
  14. 14. Examples
  15. 15. Further Reading● Official Announcement● Rightscales blog on their use● Dev Guide - Basic Concepts● AWS Ruby SDK

×