Retry, Catch, replay and cost bounds
Bound retries and recover explicitly
A temporary network failure may succeed on another attempt; invalid input usually will not. In ASL, a retrier matches an error name, waits, and retries up to MaxAttempts additional attempts. When retry is exhausted, a matching catcher can route to a recovery state. This is a fragment for a JSONPath Task, not a deployable state machine; Recover must be defined in the complete machine.
{ "Retry": [ { "ErrorEquals": [ "TemporaryError" ], "IntervalSeconds": 2, "BackoffRate": 2, "MaxAttempts": 2 } ], "Catch": [ { "ErrorEquals": [ "TemporaryError", "InvalidOrder" ], "ResultPath": "$.failure", "Next": "Recover" } ]}Retry math and failure boundaries
For the fragment, a temporary error causes at most three total task attempts, with delays of 2 and 4 seconds before retries (no jitter here). An InvalidOrder goes straight to Recover. Use explicit error names, task timeouts, an overall deadline and bounded Map concurrency; jitter and maximum delay can reduce synchronized retries when configured. Retry and Catch are not universal handlers for every terminal or data-processing error. Preserve error context without logging sensitive payloads. Catch is not a transaction rollback; compensation is separate business logic.
Replay is another delivery
Classic archive/replay sends selected historical events back to the original bus, optionally selecting rules. The newer Custom Event Bus instead supports reading retained events from a chosen subscriber starting point. Verify the retention and delivery settings for your bus type. Neither means undoing old work. Replay can repeat an email or reservation unless the consumer checks a persistent business key. In a real system couple the deduplication record and local state update atomically, and design external calls with their own idempotency contracts. Never replay a broad time range without estimating effects, restricting targets and reviewing a stop plan.
Cost and observability
Standard charges by state transitions, including retries; Express charges by executions, duration and memory, plus applicable downstream services. Suppose 100 Standard executions each incur 4 billed transitions, and 20 extra retries each add one transition. That is 420 transitions. At an invented rate of $0.00003 per transition, the subtotal is $0.0126 before free allowances, taxes, logging, events, storage and target charges. This is not a current AWS price. Check EventBridge event ingestion/delivery, archive/replay or retention charges for the selected type and region. Monitor failed deliveries separately from failed workflows; correlate business event IDs with execution IDs. Standard history and Express logs have different retention and visibility.
Practice a safe recovery plan
Predict three outcomes: temporary error then success; three temporary failures; invalid order. Use the local model to verify attempt counts and recovery. For a replay of 100 order events, require a narrow time range, known schema versions, durable deduplication, bounded target throughput, explicit approval and a stop condition. The lab runs without credentials, timers, external calls or cloud cost. Next: ECR and container distribution.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Retry, Catch, replay and cost bounds — knowledge check
Apply the lesson to offline event and workflow scenarios.
MaxAttempts is 2. How many total attempts can a matching failure cause?
IntervalSeconds=2 and BackoffRate=2, with no jitter. What are the first two retry delays?
InvalidOrder occurs in the sample fragment. What happens?
How should an already processed order be handled during replay?
100 executions have 4 billed transitions each; 20 retries add one each. How many transitions?