DEV Community

Anupa Supul
Anupa Supul

Posted on

What Happens When a Serverless Workflow Has 10 Steps? Understanding AWS Step Functions

In my previous articles, I explored AWS Lambda, API Gateway, DynamoDB, SQS, SNS, and EventBridge.

Each service solves a specific problem. But as I learned more about serverless architecture, I started thinking about another challenge.

What happens when an application needs to coordinate many tasks, handle failures, and decide what to do next?

Imagine an online shopping application.

When a customer places an order, the system might need to validate the order, process payment, update inventory, arrange delivery, and send a confirmation.

Some steps must happen in a particular order. Some can run in parallel. Others might need to be retried if they fail.

Managing all this logic inside one large Lambda function can become difficult.

This is where AWS Step Functions becomes useful.

1. What Is AWS Step Functions?

AWS Step Functions is a workflow orchestration service that helps coordinate multiple tasks into a defined workflow.

It uses state machines to describe how a process moves from one step to another.

A workflow can invoke Lambda functions, integrate with supported AWS services, make decisions, run tasks in parallel, and handle errors.

Instead of manually managing every transition in your application code, you define the workflow and its behavior.

Think of it this way:

  • Lambda executes a task.
  • Step Functions coordinates the tasks.

2. How Does It Work?

Consider a simplified order-processing workflow.

Customer Places Order
         |
         v
    Validate Order
         |
         v
    Process Payment
         |
         v
   Update Inventory
         |
         v
   Send Confirmation
         |
         v
    Order Complete
🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน 🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน

Each step performs a particular responsibility. Step Functions manages the transitions between those steps.

If payment fails, for example, the workflow can follow a defined error-handling path rather than blindly continuing to update inventory.

This makes complex business processes easier to understand and maintain.

3. Understanding State Machines

A state machine defines the states in a workflow and how execution moves between them.

In Step Functions, common state types include:

  • Task: Performs work, such as invoking Lambda.
  • Choice: Selects a path based on a condition.
  • Parallel: Executes branches concurrently.
  • Wait: Pauses execution for a specified period.
  • Succeed: Marks successful completion.
  • Fail: Marks unsuccessful completion.
  • Pass: Passes data through or provides a simple transformation.

For example, after payment processing, the workflow could check the result.

       Process Payment
              |
              v
       Payment Successful?
           /       \
         Yes        No
          |          |
          v          v
 Update Inventory  Handle Failure
          |
          v
    Confirm Order
🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน 🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน

The workflow is not just a sequence of functions. It can include decisions, parallel tasks, waiting periods, and error-handling paths.

4. What Happens When a Task Fails?

Failures are normal in distributed systems. An external API might be temporarily unavailable, or a service might return an error.

Step Functions lets you define retry and error-handling behavior for supported workflow states.

For example, a task can retry a temporary failure before moving to a fallback path.

       Process Payment
              |
              v
          Task Failed
              |
              v
         Retry Task
              |
        +-----+-----+
        |           |
      Success     Failed Again
        |           |
        v           v
   Continue      Handle Error
🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน 🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน

You can configure retry policies with parameters such as the error types to retry, the number of attempts, and the delay between attempts.

You can also configure catch behavior to move to another state when an error matches the configured conditions.

However, a retry does not guarantee that an operation is safe to repeat. If a payment request succeeds but the response is lost, repeating it could create a duplicate charge unless the payment operation supports appropriate idempotency.

Important lesson: Workflow orchestration helps manage failures, but your application still needs correct error handling and idempotent operations.

5. A Real-World Architecture

Let's connect Step Functions with the AWS services we've already explored.

AWS Step Functions order-processing workflow architecture

An illustrative order-processing workflow using API Gateway, Lambda, Step Functions, and supporting AWS services.

Here is a simplified architecture diagram in text form:

             React Frontend
                    |
                    v
               API Gateway
                    |
                    v
                AWS Lambda
                    |
                    v
            AWS Step Functions
                    |
             Validate Order
                    |
                    v
             Process Payment
                    |
                    v
          +---------+---------+
          |                   |
          v                   v
    Update Inventory    Record Order Status
          |                   |
          +---------+---------+
                    |
                    v
             Send Notification
                    |
                    v
              Order Complete
🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน 🏆 ยอดนิยม: anupa supul/what happens when a serverless workflow has steps understanding aws step functions ig - ประเด็นร้อน

This is a conceptual architecture; the exact integration can vary depending on the application.

Step Functions can invoke Lambda functions or integrate directly with supported AWS services. For longer-running or asynchronous tasks, a workflow can also wait for an external task to complete using supported integration patterns.

For example, you could use:

  • API Gateway to receive the request.
  • Lambda to validate and initiate the workflow.
  • Step Functions to coordinate order processing.
  • DynamoDB to store order data.
  • SNS to distribute notifications.
  • CloudWatch to monitor workflow activity and failures.

The benefit is separation of responsibilities. Each component focuses on its job, while the workflow defines how the overall process fits together.

6. Standard vs. Express Workflows

AWS Step Functions offers two workflow types: Standard and Express.

Feature Standard Express
Typical use Long-running, durable workflows High-volume, short-duration workflows
Maximum duration Up to one year Up to five minutes
Execution model Exactly-once workflow execution model, with integration-specific considerations At-least-once or at-most-once execution, depending on the mode
Common use cases Order processing, approvals, business workflows High-volume event processing, data transformation

The execution model matters. Even when a Standard workflow has an exactly-once execution model, an external side effect may still need idempotency, especially when the workflow retries an integration or an external system's response is uncertain.

Choose the workflow type based on the duration, throughput, reliability, and execution requirements of the process.

7. When Should You Use AWS Step Functions?

Step Functions is useful when:

  • A process contains multiple dependent tasks.
  • You need conditional logic or parallel execution.
  • You want clearly defined retry and error-handling behavior.
  • You need to coordinate multiple AWS services.
  • You want a visible execution history to help troubleshoot workflows.

It may be unnecessary for a simple API that only performs one short operation. A single Lambda function may be enough for that.

The goal is not to use Step Functions everywhere. It is to use it when workflow complexity makes orchestration worthwhile.

8. My Main Takeaways

As I continue learning AWS, I'm realizing that building cloud applications involves more than understanding individual services. It also means understanding how those services work together to implement real business processes.

My mental model is simple:

  • Lambda performs individual tasks.
  • Step Functions coordinates workflows.
  • SQS queues work for asynchronous processing.
  • SNS distributes notifications.
  • EventBridge routes events based on rules.
  • DynamoDB stores application data.
  • CloudWatch helps monitor the system.

Each service has a different responsibility, and choosing the right combination depends on the problem you're solving.

For me, AWS Step Functions is an important piece of the puzzle because it helps turn a collection of individual cloud services into a coordinated workflow.

I'm continuing to document my AWS learning journey one concept at a time. If you're learning AWS too, I'd love to hear what you're building and which services you're exploring.

Top comments (0)