Combine Step Functions Standard and Express workflows for fun & profit
Tags: aws, serverless, stepfunctions
Published: 2023-09-04 23:54:55

---
title: Combine Step Functions Standard and Express workflows for fun & profit
published: true
date: 2023-09-04 06:45:03 UTC
tags: AWS,Serverless,StepFunctions
canonical_url: https://theburningmonk.com/2023/09/combine-standard-and-express-workflows-for-fun-profit/
---

Step Functions’ state machines come in two flavours. By understanding their strengths and limitations, you can harness the combined power of both to optimize your processes for efficiency and cost.

![](https://theburningmonk.com/wp-content/uploads/2023/09/img_64f579c135a19-1024x699.png)

**Standard Workflows**

Optimal for: Business-critical operations like payment processing.

Strengths:

- Suitable for low-throughput scenarios.
- High maximum duration ensures enough time for retries using exponential backoff.
- Offers exactly-once execution to avoid duplicate processing.

Limitations:

- Rate limits can be restrictive for high-frequency tasks.
- Charges are based on state transitions.

**Express Workflows**

Optimal for: High-throughput scenarios.

Strengths: Cost-effective for tasks with many state transitions.

Limitations:

- Lower maximum duration can be a challenge.
- Execution semantics might not be suitable for all use cases.

Broadly speaking, this is where I think they stand.

![](https://theburningmonk.com/wp-content/uploads/2023/09/img_64f57c72b0c86.png)

But you can combine them and get the best of both worlds.

Imagine a workflow that:

- Runs frequently but stays within the rate limits of Standard Workflows.
- Occasionally requires more than 5 minutes to execute.
- Requires no duplicate processing of input.
- Has a lot of state transitions.

While points 2 and 3 suggest the need for a Standard Workflow, point 4 indicates that this would be a costly choice due to charges based on state transitions.

**The Solution** : Integrate both workflows. Place the high-frequency tasks within an Express Workflow, which charges based on execution time and memory usage. Then, nest this Express Workflow within a Standard Workflow that handles orchestration and control flow. Any extended waits or callbacks should be managed within the parent Standard Workflow.

![](https://theburningmonk.com/wp-content/uploads/2023/09/img_64f57cad97895.png)

The Standard Workflow helps you mean the requirements for point 2 and 3. While the nested Express Workflow mitigates the cost explosion from the high number of state transitions.

### Summary

By segmenting your processes into high-frequency (many transitions, short duration) and slow-reacting (long waits, callbacks) components, you can maximize the advantages of both Standard and Express workflows. The overarching Standard Workflow ensures long-duration processing with exactly-once execution, while the nested Express Workflow offers cost benefits for rapid tasks.

Thank you, [Robbie Kohler](https://www.linkedin.com/in/rkohler/), for showing me this ingenious approach.

Talk about having one’s cake and eating it too!

The post [Combine Standard and Express workflows for fun & profit](https://theburningmonk.com/2023/09/combine-standard-and-express-workflows-for-fun-profit/) appeared first on [theburningmonk.com](https://theburningmonk.com).