Designing Durable Workflows with Step Functions and Lambda Durable Functions
This lesson explains durable execution and compares Step Functions Standard and Express Workflows with Lambda durable functions for multi-step processes.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how Step Functions and Lambda durable functions preserve progress through failures and waits.
- Describe why durable function code outside steps must be deterministic.
- Choose a durable execution model from duration, volume, audit and development requirements.
AWS Step Functions
Step Functions defines a workflow as a state machine in Amazon States Language. Standard Workflows run for up to one year, perform each state transition exactly once and keep a full execution history that shows every step's input, output and errors. Express Workflows run for up to five minutes at very high volume with at-least-once semantics and are charged by requests and duration. Built-in Retry and Catch policies, Parallel and Map states (including Distributed Map for millions of items), direct integrations with more than 200 AWS services and the .waitForTaskToken callback pattern let workflows coordinate services with little code.
Step Functions or durable function?
Lambda durable functions
Lambda durable functions express the workflow as ordinary code in one Lambda function, written with the Durable Execution SDK (available for several languages, including Python, Node.js and Java). Each step runs with retries and its result is checkpointed. When the function waits, for a duration, a condition or an external callback, it stops running and stops charging; Lambda later invokes it again and replays the checkpoint log, returning stored results for completed steps. A durable execution can run for up to one year, and an execution timeout and a retention period for its history are configured on the function.
Because the handler runs again from the beginning on every replay, code outside steps must be deterministic: random values, timestamps and calls with side effects belong inside steps.
Lambda durable functions
Choosing between them
Loan origination
A lender's application process checks identity, pulls a credit report from an external API, waits up to ten days for documents and for an underwriter's decision, and must show regulators every step.
The architect uses a Standard Workflow: service integrations call the identity and credit services with retries, and two task token steps wait for the document upload and the underwriter, each with a timeout.
A separate team that builds a document-enrichment process as Python code chooses a Lambda durable function, because its logic is mostly code and the waits for a third-party OCR callback should cost nothing; the random reference number it generates is created inside a step so replays keep the same value.
Why would a team choose a Standard Workflow over a Lambda durable function for a regulated process?
Show answer
A Standard Workflow keeps a complete, visual execution history of every state's input and output, which auditors can review, and orchestrates AWS services through direct integrations.
Exam Tips
Remember for the exam
- Long-running, auditable workflow across AWS services: Step Functions Standard Workflows.
- Very high-volume, short workflows with idempotent steps: Express Workflows.
- Long-running process written as code with waits that cost nothing: Lambda durable functions.
- Durable function returns different values after resume: move non-deterministic code into a step.