Course contentsShow
← Cloud and Infrastructure
Lesson 2525 of 2,98954. Serverless ArchitecturesFree lesson

Long-Running Workflows

Designing workflows for processes spanning hours or days, handling timeouts, and implementing human approval steps.

Long-Running Workflows

You'll learn how to design serverless workflows that safely run for hours or days while handling timeouts and human interventions.

The Challenge of Extended Processes

Not every workflow completes in seconds. Think order fulfillment, document approvals, or data pipeline jobs—these can span hours or days. In serverless architectures, where functions typically timeout after minutes, you need orchestration tools specifically designed for durability and long waits.

Core Design Principles

Durable Execution: Step Functions (AWS), Durable Functions (Azure), and Cloud Workflows (Google) persist workflow state automatically. If a task takes 6 hours, the orchestrator simply waits—no server running continuously, no lost state.

Timeout Strategies: Set explicit timeouts at the task and workflow level. Use TimeoutSeconds in Step Functions to fail fast when tasks hang, preventing indefinite waits and runaway costs.

Human-in-the-Loop: Long workflows often need approvals. Implement this by:

  • Pausing workflow execution at a decision point
  • Sending notifications (email/Slack) with approval links
  • Using callback tokens that resume execution when someone responds
  • Setting timeout limits for approval windows (e.g., auto-reject after 48 hours)

Pattern Example

A document approval workflow might:

  1. Submit document (task, 30s)
  2. Wait for manager approval (callback, 48-hour timeout)
  3. If approved → process document (task, 2 hours)
  4. If timeout → escalate to director (callback, 24-hour timeout)

Each step can take hours, but you only pay for actual execution time, not waiting periods.

Key Takeaway: Long-running serverless workflows require orchestration platforms that persist state across arbitrary wait times, implement defensive timeouts, and support callback patterns for human interactions—enabling complex processes without dedicated infrastructure.