Amazon Web Services

Orchestration — AWS Step Functions

Coordinate a multi-step workflow with retries, branching and compensation, without writing the state machine yourself.

Step Functions runs a workflow defined as a state machine, so the retries, timeouts and branching live in configuration rather than in your code.

A factory production line with a written procedure at every station: what to do, how many times to retry, and which earlier steps to undo if this one fails for good.

Key Concepts

1
    [Validate] -> [Reserve stock] -> [Charge card] -> [Ship]
                        |                  |
                     failed            declined
                        v                  v
                  [Cancel order]   [Release stock] -> [Notify]
2
What it replaces. A Lambda that calls four services, catches each failure, decides what to retry and unwinds what already succeeded — logic that is hard to read and harder to test.
3
Retries and catches are declared per state.
    "Retry": [{ "ErrorEquals": ["States.Timeout"],
                "IntervalSeconds": 2, "MaxAttempts": 3,
                "BackoffRate": 2.0 }],
    "Catch": [{ "ErrorEquals": ["States.ALL"], "Next": "Compensate" }]
4
Exponential backoff you would otherwise write by hand, in four lines.
5
Standard or Express.
    Standard  up to 1 year, exactly-once, full execution history,
              priced per state transition. Long business processes.
    Express   up to 5 minutes, at-least-once, priced per request.
              High-volume short workflows -- far cheaper at scale.
6
The saga pattern is the usual interview framing. Distributed transactions have no two-phase commit here, so each step gets a compensating action and failure walks them backwards. Step Functions makes that explicit rather than implied.
7
The state types worth knowing.
    Task      do work: Lambda, ECS, SQS, DynamoDB, 200+ integrations
    Choice    branch on the data
    Parallel  run branches concurrently, join at the end
    Map       fan out over an array, with a concurrency limit
    Wait      pause for a time or until a timestamp
8
Callbacks let a workflow wait for something outside it. A task token pauses execution until a human approves or an external system calls back — up to a year for Standard.
9
The cost to weigh. Standard charges per state transition, so a chatty workflow in a hot path gets expensive. That is what Express mode is for.
10
What the interviewer is probing.1. "Why use Step Functions rather than a Lambda calling four services?" Probing: where the retry logic lives. Stalls: "It looks nicer." Moves up: retries, backoff, timeouts and compensation are declared per state rather than written, and every execution has a visible history showing where it stopped.
11
2. "Standard or Express?" Probing: the two modes. Stalls: "Standard." Moves up: Standard for long business processes with exactly-once and full history; Express for high-volume short workflows, priced per request and at-least-once.
12
3. "How do you implement a distributed transaction here?" Probing: saga. Stalls: "Use a transaction." Moves up: there is none — each step gets a compensating action and failure walks them backwards, which Step Functions makes explicit.
13
4. "How do you pass a large payload between states?" Probing: the size limit. Stalls: "In the state." Moves up: the payload is capped at 256KB, so write to S3 and pass the pointer.