Sub topic 10
Choosing Standard or Express workflows
This chapter assumes you can read a state machine definition in Amazon States Language and have used Task, Retry, and Catch. It covers the two workflow types, what each guarantees, and how to pick one for a given job.
The type is a property of the state machine
Every state machine has a type, either STANDARD or EXPRESS. You choose it when you create the state machine, and you cannot change it afterward. To switch, create a new state machine with the same definition and move callers over to it.
The two types accept the same Amazon States Language. They differ in how long an execution may run, how many may run at once, what delivery guarantees apply, which integration patterns are allowed, how history is kept, and how you are billed.
Standard workflows
Standard workflows are built for long-running, auditable processes.
- Duration: An execution can run for up to one year.
- Execution semantics: Each state runs exactly once, except where you configure a Retry. Step Functions does not run a state twice because of its own internal retries.
- History: Step Functions stores the execution history for 90 days. You can read it in the console or with
GetExecutionHistory, without setting up logging. - Integration patterns: All three patterns work: request-response,
.sync, and.waitForTaskToken. Activities (worker polling) are also supported. - Billing: You pay per state transition. Every state entered, and every retry, counts as a transition.
- Idempotent start: Calling
StartExecutionwith the name and input of an execution that is still running does not start a second one. This helps clients that retry on timeouts.
A single execution history holds at most 25,000 events. A loop that runs for a long time can hit that cap, so long-lived workflows often restart themselves or hand work to a child execution.
Express workflows
Express workflows are built for high-volume, short-lived work such as event processing, data transformation, and API backends.
- Duration: An execution can run for at most five minutes.
- Volume: Express supports a much higher start rate than Standard, over 100,000 executions per second in the default quotas of many Regions.
- Billing: You pay for the number of executions, plus duration and memory used. There is no per-transition charge, so a workflow with many cheap states costs far less than on Standard.
- History: The console does not keep history for you. Execution data exists only if you enable logging to CloudWatch Logs.
- Integration patterns: Only request-response is available. A Task state cannot use
.syncor.waitForTaskToken, and Express workflows cannot use Activities.
Two ways to run an Express workflow
| Mode | API call | Behavior | Guarantee |
|---|---|---|---|
| Asynchronous | `StartExecution` | Returns right away. The result goes only to logs or downstream states. | At-least-once |
| Synchronous | `StartSyncExecution` | Waits and returns the status and output in the response. | At-most-once |
The guarantees matter for design. An asynchronous Express execution may run more than once for a single request, and the workflow can repeat side effects. A synchronous one never retries on its own, so if the call fails you must decide whether to call again. In both cases, make the steps idempotent: the same input should leave the same end state no matter how many times it runs.
Side-by-side comparison
| Property | Standard | Express |
|---|---|---|
| Maximum duration | 1 year | 5 minutes |
| Start rate | Thousands per second | Over 100,000 per second |
| Execution guarantee | Exactly-once | At-least-once (async), at-most-once (sync) |
| `.sync` and `.waitForTaskToken` | Supported | Not supported |
| Activities | Supported | Not supported |
| History | 90 days, built in | CloudWatch Logs only |
| Billing unit | State transitions | Executions, duration, memory |
| Synchronous start | No | Yes, `StartSyncExecution` |
Exact quotas change and vary by Region. Check the Service Quotas page before sizing a workload.
A decision procedure
Work through these questions in order. The first one that forces a choice settles it.
- Can it exceed five minutes? If yes, choose Standard.
- Does any step wait for a person, an external system, or a long job?
.waitForTaskTokenand.syncneed Standard, so choose Standard. - Would a duplicate run cause harm that you cannot prevent with idempotent steps? Payments and inventory decrements are examples. Choose Standard for exactly-once semantics.
- Does the caller need the result in the same request? An API Gateway backend is one. Choose synchronous Express.
- Is the volume very high and each run short? Choose Express, because Standard transition costs add up quickly.
- Do you need built-in history for audits or debugging with no setup? Choose Standard, or make sure Express logging is on.
Creating and calling an Express workflow
An Express state machine needs logging if you want any record of what happened. This command creates one with logging set to ALL. It assumes definition.json exists and the log group name starts with /aws/vendedlogs/states/, which avoids a CloudWatch Logs resource policy size limit.
aws stepfunctions create-state-machine \
--name OrderValidateExpress \
--type EXPRESS \
--definition file://definition.json \
--role-arn arn:aws:iam::123456789012:role/OrderWorkflowRole \
--logging-configuration '{
"level": "ALL",
"includeExecutionData": false,
"destinations": [
{"cloudWatchLogsLogGroup": {
"logGroupArn": "arn:aws:logs:us-east-1:123456789012:log-group:/aws/vendedlogs/states/OrderValidate:*"
}}
]
}'includeExecutionData is false here. Setting it to true writes each state's input and output to the logs, which helps debugging but can expose sensitive data and raises log costs.
A synchronous call returns the result directly:
import json
import boto3
sfn = boto3.client("stepfunctions")
def validate(order_id: str) -> dict:
response = sfn.start_sync_execution(
stateMachineArn="arn:aws:states:us-east-1:123456789012:stateMachine:OrderValidateExpress",
input=json.dumps({"orderId": order_id}),
)
if response["status"] != "SUCCEEDED":
raise RuntimeError(f"{response.get('error')}: {response.get('cause')}")
return json.loads(response["output"])StartSyncExecution reports a failed workflow in the response's status, not by raising an exception. Always check status before reading output.
Combining both types
You do not have to pick one type for a whole system. A common design uses a Standard workflow as the coordinator and Express workflows for the short, high-volume parts. The coordinator can wait for approvals and keep a long audit trail. Its children do the fast work.
A Standard parent calls an Express child with the AWS SDK integration for StartSyncExecution. The .sync variant of states:startExecution is for Standard children, so it does not apply here.
{
"StartAt": "RunFastValidation",
"States": {
"RunFastValidation": {
"Type": "Task",
"Resource": "arn:aws:states:::aws-sdk:sfn:startSyncExecution",
"Parameters": {
"StateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:OrderValidateExpress",
"Input.$": "States.JsonToString($)"
},
"ResultSelector": {
"validation.$": "States.StringToJson($.Output)"
},
"ResultPath": "$.result",
"End": true
}
}
}The SDK integration takes Input as a string, so States.JsonToString converts the state input. States.StringToJson turns the string Output back into JSON.
This pattern also saves money. A Standard workflow that loops through hundreds of tiny steps pays for every transition. Moving those steps into one Express child turns them into a single parent transition plus one Express execution.
Common mistakes
- Choosing Express for a workflow with a human approval step. The definition is rejected or the callback never works, because
.waitForTaskTokenis not available. Use Standard. - Assuming exactly-once on Express. Asynchronous Express can run a request more than once. Add idempotency keys or conditional writes in the Lambda functions and database calls.
- Forgetting logging on Express. Without a log destination, a failed execution leaves almost nothing to inspect. Turn on logging before the first deployment, and use
ERRORlevel ifALLis too costly. - Ignoring the five-minute limit. An Express execution that hits it ends with a timeout. Include the time spent in Retry backoff when you estimate duration.
- Using Standard for millions of tiny events. It works, but transition charges and start-rate quotas become the main cost and the main limit.
- Treating the type as a setting. Changing it means a new state machine with a new ARN. Update callers, IAM policies, and alarms that reference the old ARN.
Observability differences
For Standard, the console shows a per-state graph and event list for 90 days. For Express, the console can show execution details only when logging is on, and it reads them from CloudWatch Logs. Both types support X-Ray tracing and CloudWatch metrics. Express metrics focus on executions started, succeeded, failed, and timed out, with no per-execution history to browse. The next chapters cover IAM permissions, logs, and tracing in more detail.
Exercise
A checkout service must validate an order in under two seconds, return the result to the caller in the same HTTP request, and handle about 20,000 requests per second at peak. The validation steps are idempotent. Which workflow type and start API do you choose, and why not Standard?
Show answer
Use an Express workflow started with StartSyncExecution. The run is far shorter than five minutes, the caller needs the result in the same request, and the volume is far above what makes sense for Standard. Standard also has no synchronous start API, and its per-transition billing would cost far more at this rate. Because the steps are idempotent, Express's lack of exactly-once semantics is acceptable, and synchronous mode gives at-most-once execution anyway.
Exercise
A workflow sends an approval request to a manager and waits for as long as three days for a reply. Can it be an Express workflow? What would you change if the approval step must stay but the other steps handle 50,000 events per second?
Show answer
No. Waiting three days exceeds the five-minute Express limit, and .waitForTaskToken is not supported on Express. Make the approval workflow Standard. Move the high-volume, short steps into an Express state machine that the Standard parent calls with the aws-sdk:sfn:startSyncExecution integration, or have the event stream start the Express workflow directly and use Standard only for the approval path.