0Pricing
Serverless Backend with AWS Lambda & API Gateway · レッスン

ステートマシンのエラー処理とリトライ

ワークフローを堅牢にします。Step FunctionsのRetryおよびCatchフィールド、指数バックオフ、失敗をフォールバック状態へルーティングする方法を学びます。

「ステートマシンのエラー処理とリトライ」はCoddyKit上の無料Serverless Backend with AWS Lambda & API Gatewayレッスンです。 これはレッスン4/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはServerless Backend with AWS Lambda & API Gateway学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Serverless Backend with AWS Lambda & API Gatewayコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Failures Happen in Workflows

A Step Functions workflow chains many tasks. Any task can fail — a timeout, a throttle, or a thrown error. Built-in error handling lets the state machine recover instead of crashing.

Error Names

Step Functions classifies errors with names like States.Timeout, States.TaskFailed, and States.ALL. Your custom Lambda errors appear by their error name too.

The Retry Field

A Retry array on a Task state automatically re-runs it on matching errors.

"Retry": [{
  "ErrorEquals": ["States.TaskFailed"],
  "MaxAttempts": 3
}]

Exponential Backoff

Use IntervalSeconds and BackoffRate so each retry waits longer, easing pressure on a struggling downstream service.

"Retry": [{
  "ErrorEquals": ["States.ALL"],
  "IntervalSeconds": 2,
  "BackoffRate": 2.0,
  "MaxAttempts": 4
}]

The Catch Field

When retries are exhausted, a Catch block routes the workflow to a fallback state instead of failing the whole execution.

"Catch": [{
  "ErrorEquals": ["States.ALL"],
  "Next": "NotifyFailure"
}]

Capturing the Error

Use ResultPath in a Catch to pass the error details into the next state, so your fallback can log or react to what went wrong.

"Catch": [{
  "ErrorEquals": ["States.ALL"],
  "ResultPath": "$.error",
  "Next": "HandleError"
}]

Ordering Retry Rules

List more specific errors first. Step Functions evaluates Retry/Catch entries top to bottom, so a broad States.ALL should come last.

Timeouts as Safety Nets

Set TimeoutSeconds on a Task so a hung activity throws States.Timeout instead of running forever, which your Retry can then handle.

Fallback States

A fallback can be a Fail state that ends the execution with a clear cause, or a compensating action that undoes earlier work (the saga pattern).

Express vs Standard Error Behavior

Standard workflows keep full execution history for debugging failures; Express workflows are faster and cheaper but log to CloudWatch. Choose based on how you need to trace errors.

Designing Resilient Workflows

Combine the tools:

  • Retry transient errors with backoff
  • Catch terminal errors to a fallback
  • Set timeouts as safety nets
  • Capture error details with ResultPath

Quick Check

Test your Step Functions error-handling knowledge.

Recap

You learned resilient workflows:

  • Retry re-runs tasks on matching error names
  • IntervalSeconds and BackoffRate give exponential backoff
  • Catch routes exhausted errors to a fallback state
  • ResultPath captures the error; timeouts prevent hangs

よくある質問

「ステートマシンのエラー処理とリトライ」レッスンは無料ですか?

はい。「ステートマシンのエラー処理とリトライ」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Serverless Backend with AWS Lambda & API Gatewayコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Serverless Backend with AWS Lambda & API Gatewayコースには全4レッスンが含まれています。

「ステートマシンのエラー処理とリトライ」で何を学びますか?

ワークフローを堅牢にします。Step FunctionsのRetryおよびCatchフィールド、指数バックオフ、失敗をフォールバック状態へルーティングする方法を学びます。 ブラウザで直接実行するハンズオンコードでServerless Backend with AWS Lambda & API Gatewayを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Serverless Backend with AWS Lambda & API Gatewayを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのServerless Backend with AWS Lambda & API Gatewayは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン4/4です。

「ステートマシンのエラー処理とリトライ」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このServerless Backend with AWS Lambda & API Gatewayレッスンでコードを書いて実行できますか?

はい。すべてのServerless Backend with AWS Lambda & API Gatewayレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. AWS Step Functions入門
  2. ステートマシンの構築
  3. 複雑なワークフローのオーケストレーション
  4. ステートマシンのエラー処理とリトライ
← Serverless Backend with AWS Lambda & API Gatewayに戻る