Email copiado — support@tuurt.com
Cargando experiencia
aws · October 25, 2026 · 6 min

Step Functions vs chained Lambdas: when the state machine pays off

We moved some chained-Lambda flows to Step Functions and left others as they were. The difference was not how much code it took, but how visible the retry and branching logic stays when something fails.

By Tuurt Team

Step Functions vs chained Lambdas: when the state machine pays off

When a business flow has two or three steps in sequence, chaining Lambdas - one invokes the next, or they all listen to the same queue - is the obvious choice: no new definition language to learn, no extra service to pay for. The problem shows up once the flow stops being linear: conditional branches appear, some steps need retries with backoff, others have to wait for an external signal before continuing, and keeping that logic spread across the code of several Lambda functions calling each other starts to cost more than the initial savings of skipping Step Functions. We moved some of those flows to Step Functions and kept others as chained Lambdas, and the line between the two cases is worth explaining.

What the state machine solves that chaining Lambdas does not solve the same way

First point: declarative retries and error handling. With chained Lambdas, every function that needs to retry a call that can fail transiently - an external API that times out, a write to a table that collides under contention - has to implement its own retry logic with backoff, usually copied and pasted across functions with small variations that drift apart over time. In Step Functions, the retry is part of the state definition, not the code:

{
  "CheckInventory": {
    "Type": "Task",
    "Resource": "arn:aws:lambda:us-east-1:123456789012:function:CheckInventory",
    "Retry": [
      {
        "ErrorEquals": ["States.Timeout", "Lambda.ServiceException"],
        "IntervalSeconds": 2,
        "BackoffRate": 2.0,
        "MaxAttempts": 3
      }
    ],
    "Catch": [
      {
        "ErrorEquals": ["States.ALL"],
        "Next": "NotifyInventoryFailure"
      }
    ],
    "Next": "ReserveProduct"
  }
}

That declarative definition means the retry and error handling for each step live in one visible place, instead of being buried inside the body of a Lambda function someone has to open and read just to find out whether it retries at all.

Second point: conditional branches without an orchestrator Lambda. With chained Lambdas, a conditional branch - if the order is above a certain amount it goes through manual approval, otherwise it is processed directly - usually lives inside the code of an orchestrator function that decides which Lambda to invoke next. Step Functions represents that branch as a Choice state right in the definition:

{
  "EvaluateAmount": {
    "Type": "Choice",
    "Choices": [
      {
        "Variable": "$.orderAmount",
        "NumericGreaterThan": 500000,
        "Next": "RequiresApproval"
      }
    ],
    "Default": "ProcessDirectly"
  }
}

Third point: waiting for an external signal without keeping a Lambda alive. Some flows need to pause until something external happens - a human approval, a reply from a third-party system that arrives hours later through a webhook - and with chained Lambdas that wait forces a choice between keeping a function running, with the execution time limit that implies, or rebuilding state from scratch once the signal arrives. Step Functions has the task token pattern (waitForTaskToken): the state machine stops at that step with no compute running, and resumes exactly where it left off once something calls SendTaskSuccess with the matching token.

What the first demo does not show: the cost that shows up later

With a three- or four-state flow, Step Functions looks simple: you draw the flow in the console, each state is a Lambda, and it all works. The operational complexity that is not obvious at first shows up on several fronts.

Testing locally stops being trivial. With chained Lambdas, testing the whole flow locally means invoking one function after another with sam local invoke or straight from the code, because the orchestration lives in Node or Python code that runs the same on a laptop as it does in the cloud. The state machine, instead, is a managed AWS resource: there is no native way to run Choice, Retry, Parallel, and Wait logic outside of an AWS account. The Step Functions Local Docker container AWS offers covers part of this, but it requires keeping the ASL definition in sync between the local and remote environments, and it does not exactly simulate every behavior of the real service, particularly around concurrency limits and direct integrations with other services that bypass Lambda.

The ASL definition is a new language the team has to learn. Amazon States Language is JSON, but JSON with its own semantics - Choice, Parallel, Map, Wait, and how ResultPath and InputPath pass data between states - that does not read like imperative code. Debugging why a misplaced InputPath makes a state receive an empty payload is a category of error that a developer used to chained Lambdas in code has no instinct for recognizing right away.

Versioning the state machine is not the same problem as versioning code. Changing an ASL definition in production - adding a state, changing a Choice condition - immediately affects any new execution, but executions already in flight when the change was published keep following the definition they started with. That is correct and necessary, but it means two executions started minutes apart can end up taking different paths for the same event, and diagnosing a discrepancy a support ticket reports requires checking which version of the definition that specific execution started with, not just what the current definition is.

Debugging a failed execution in Standard Workflows is not the same as reading CloudWatch logs. The Step Functions console shows the execution history step by step, which is genuinely useful, but when the failure is in the payload one state passed to the next - a field renamed between two Lambdas - the information is split between the Step Functions history view and the CloudWatch logs of the specific Lambda that failed, and the two sources have to be correlated by hand because they are not unified into a single trace by default.

Where we decided chained Lambdas are still the right call

We did not migrate everything to Step Functions. A strictly linear flow of two or three steps, with no conditional branches and no need to wait for an external signal, stays as chained Lambdas with an SQS queue between each step: the queue already gives retries with a configurable retry policy and a dead-letter queue for cases that exhaust their retries, with no need to learn ASL or pay for state transitions in a flow that never branches. We also did not migrate flows where per-step latency is critical and where invoking a Lambda directly, without the overhead of evaluating the state machine definition on every transition, is preferable.

We specifically migrated flows with real conditional branches, retries with different policies per error type, or a step that needs to wait for an external signal without keeping compute running while it waits. There, the cost of learning ASL and of debugging across two tools pays for itself against orchestration logic that would otherwise live hidden, barely visible, inside the code of an orchestrator Lambda nobody fully understands anymore.

What we check before moving a flow to Step Functions

Before migrating a flow from chained Lambdas to a state machine, we first confirm the flow has real conditional branches or needs to wait for an external signal, because if it is strictly linear, a queue with a dead-letter queue solves the same problem without the cost of learning a new definition language. We check that the team is willing to debug executions by correlating the Step Functions history with the CloudWatch logs of each Lambda it invokes, instead of assuming the Step Functions console alone tells the whole story. And we document which version of the ASL definition each relevant change started from, because the support question "why did this execution behave differently from yesterday's" is almost always answered by comparing definitions, not code behavior.

aws step-functions lambda serverless
← Back to blog