We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10
Amazon SWF (Simple Workflow Service)
• Amazon Simple Workflow Service (SWF) is a
managed workflow service by AWS that allows for the coordination of tasks in distributed applications. • Particularly useful for complex workflows that include both automated and human steps. Key Concepts in Amazon SWF • Workflow: A series of steps (tasks) defined by the developer, representing the overall business process. • Workflows can contain decision points and branching logic. • Tasks: The individual units of work in the workflow. There are two types: • Activity Tasks: Actions executed by a worker (e.g., processing a payment). • Decision Tasks: Logic that determines the next steps in the workflow (e.g., deciding the next task based on previous task results). Key Concepts in Amazon SWF • Domains: Logical partitions for separating workflows. • Domains allow workflows for different applications, teams, or departments to be organized and managed independently. • Workers and Deciders: • Workers: Applications that poll SWF to pick up and execute activity tasks. • Deciders: Applications that poll SWF to manage the flow of tasks, making decisions about the next steps. Amazon SWF Workflow Execution: Step- by-Step • Define the Workflow: Create a workflow using SWF APIs, defining the sequence and conditions for each task. • Start Workflow Execution: Trigger a workflow instance in SWF. SWF assigns tasks to workers based on the defined sequence and logic. • Worker Polling: Workers (applications or services) poll SWF for tasks, perform the work, and report back when a task is complete. • Decision Making: Deciders process the outcome of tasks and control the next step in the workflow, e.g., trigger another task or end the workflow. • Monitoring: SWF logs the entire execution history, enabling easy tracking and troubleshooting. Example 1: Order Fulfillment in E- commerce • An e-commerce company wants to automate its order fulfillment process. The workflow includes several steps like inventory check, payment processing, packing, and shipping, with specific conditions and retries at each step. • Inventory Check: An SWF worker checks the inventory. If the item is in stock, it proceeds; otherwise, it pauses the workflow until inventory is updated. • Payment Processing: SWF schedules an activity for payment. If payment fails, SWF retries up to three times or cancels the order if it cannot be processed. • Packing: Once payment is successful, a packing worker is notified to prepare the package. • Shipping: The final step sends shipping information to the logistics team or carrier service. Example 2: Media Processing Pipeline • A media company uses SWF to automate the video processing pipeline. This workflow includes tasks for video encoding, watermarking, and uploading to a content delivery network (CDN). • Video Encoding: A worker application encodes the video in various formats. If the encoding task fails, SWF can retry automatically or alert a human operator. • Watermarking: Once encoding is complete, SWF schedules a watermarking task to overlay a logo on the video. • Quality Check: A human operator reviews the watermarked video for quality assurance. • Upload to CDN: After the quality check, SWF uploads the video to a CDN for distribution. Example 3: Financial Transactions and Approvals • In the financial sector, SWF can help manage processes like loan approvals, which require multiple steps and human approvals. • Application Submission: A worker application submits the loan application. • Risk Analysis: SWF assigns an activity task to analyze the applicant’s credit risk. Based on the analysis, a decider may branch to a different workflow path if high risk is detected. • Approval Process: If the applicant meets the criteria, SWF triggers a decision task that sends the application to a human underwriter for review. • Final Approval: Once reviewed, SWF assigns the final approval task, notifying the applicant of the result. Human-in-the-Loop Document Review • In industries like legal, healthcare, or insurance, document processing often requires human review. SWF can manage a workflow that combines automated and manual steps. • Document Ingestion: A worker uploads a new document and initiates the workflow. • Automated Preprocessing: SWF assigns tasks for OCR (Optical Character Recognition) to convert scanned documents into text and perform initial data extraction. • Human Review: After preprocessing, SWF triggers a manual review task where a human validates the extracted data for accuracy. • Approval and Storage: Once the review is complete, the document is marked as approved and stored in a database. Comparison to AWS Step Functions • Complexity: SWF is designed for complex workflows, especially those involving human interaction, long- running tasks, and legacy system integration. • Control: SWF offers fine-grained control over workflow execution, such as task timeouts and retries. • Long-Running Workflows: SWF supports workflows that can last days or weeks, unlike Step Functions, which is more suited for short-lived or serverless workflows. Benefits of Amazon SWF • Reliability: SWF ensures workflow consistency even in the face of errors or failures. • Scalability: It can handle thousands of parallel workflows across large-scale applications. • Auditing: SWF provides a comprehensive execution history, allowing for easy tracking and troubleshooting. • Cost-Effectiveness: SWF’s pay-as-you-go pricing means you only pay for the resources used.