How do a function platform's asynchronous retry count and maximum event age interact, and how would you set them for an unreliable downstream?
answer
- two limits, whichever comes first
- attempts versus elapsed time
- throttled waiting still ages the event
- side effects decide the count
- freshness decides the age
basics
~20 sRetry count caps attempts; maximum event age caps time since acceptance, including time queued while throttled. Whichever runs out first ends the retries. Set the count from the handler's side effects and the age from how long the event stays useful.
solid answer
~50 sOn the asynchronous path, the **retry count** limits how many more attempts follow a failure and the **maximum event age** limits how long the platform keeps trying from the moment it accepted the event. They race: an event leaves the retry loop when either runs out and goes to the failure destination, or is dropped. Age counts every second, including backoff gaps and time spent queued while the function was throttled, so a tight concurrency cap and a short age can expire events that never ran. I set the **count** from the side effects: an idempotent write can take every retry, while a non-idempotent charge or email gets few or none. I set the **age** from usefulness: a notification that is stale after minutes gets a short age, a ledger event a long one. Neither setting bridges an outage of hours; the failure destination and a redrive do.
go deeper
Remember the two limits: retry count caps attempts, maximum event age caps time. Whichever comes first sends the event to the failure destination.
Explain that the age clock includes backoff and throttled waiting, and choose the count from side effects and the age from how long the event stays useful.
Show you check these settings together with the concurrency cap, and that you plan long outages around a destination and a redrive, not bigger retry counts.
Turn the per-handler reasoning into a classification teams declare once, side effect and freshness, so retry settings follow from it instead of being guessed.
## Two limits on one retry loop When a function invoked asynchronously fails, the platform retries it with a growing delay (a **backoff**) between attempts. Two operator settings end that loop: - **Retry count** - the number of extra attempts after the first failure. It bounds how many times the handler's side effects can run for one event. - **Maximum event age** - the longest time the platform keeps an event, measured from when it accepted it. It bounds how late an event can be processed. They are independent limits on the same loop, and **whichever is reached first wins**. Once one of them is hit, the event goes to the failure destination if one is configured, or is discarded. | Situation | Limit that ends it | Typical cause | |---|---|---| | Handler fails fast on every attempt | Retry count | A bug, a bad payload, a downstream that rejects the call | | Handler is throttled and never runs | Maximum event age | A per-function concurrency cap far below demand | | Long backoff between slow attempts | Either, depending on settings | A downstream that times out slowly | ## Why time spent waiting counts The age clock does not pause. It runs during backoff gaps between attempts, and it runs while the event sits in the platform's internal queue waiting for a free instance. That second case surprises people. If a per-function concurrency cap is set low to protect a database, asynchronous events back up behind it. On most platforms those events are not rejected; they wait, and they age. With a short maximum event age, events can expire without the handler ever running once, and the function's error metric stays flat because nothing failed. The only trace is in the failure destination or in a dropped-events metric, if the platform publishes one. So check the two settings together with the concurrency cap: an event's age budget must cover the longest backlog you expect to queue behind that cap. ## Choosing the retry count: what does a repeat cost? Every retry runs the handler again from the top. The right count follows from what a repeat does: 1. **Idempotent work** (an upsert keyed by an order ID, writing a file to a fixed path) can take every retry the platform allows; a repeat is harmless. 2. **Non-idempotent side effects** (charging a card, sending an email, calling a partner that is not idempotent) should get few or no platform retries. Retry inside the handler around the one call that is safe to repeat, and let anything else go to the failure destination for a deliberate replay. 3. **Calls to a struggling downstream** multiply load: each failing event becomes several calls. If the caller in front also retries, the load multiplies again. A smaller count, or a circuit breaker in the handler, keeps retries from deepening an outage. ## Choosing the maximum event age: when is the event worthless? The age is a business answer, not a technical one. Ask how late the event can arrive and still be right: - A **push notification** or a "your ride is here" message is useless after minutes. Give it a short age so a late event lands in the destination instead of firing an hour late. - A **price or stock alert** may be harmful when late. Short age, and a destination someone reviews. - A **ledger entry** or an **order-placed event** must never be lost and is still correct days later. Give it the longest age the platform allows and a destination with long retention. ## What neither setting can do A platform's retry window is short compared with real outages. If a downstream is down for a weekend, no retry count gets the events through; turning the count up only adds load and duplicate attempts during the outage. Plan for it instead: - Make sure every such function has a **failure destination** and an **alarm** on it. - Keep the destination's **retention** longer than the longest outage you might not notice. - Have a **redrive** path that sends recorded events back through the normal route, at a controlled rate, after the fix. ## A worked choice An order-events pipeline has three asynchronous consumers. The stock reservation handler is idempotent, so it keeps the platform's full retries and a long age. The confirmation email handler is not idempotent and is stale after a short while, so it gets no platform retries and a short age, with failures reviewed from the destination. The ledger poster is idempotent but must never be dropped, so it keeps full retries, the longest age and a destination that pages its owner.
- A function has a tight per-function concurrency cap and a short maximum event age. Events go missing but the error rate is zero. What is happening?Asynchronous events are queuing behind the concurrency cap and ageing while they wait. When the age runs out they expire without a single attempt, so no error is recorded. Look in the failure destination or a dropped-events metric, then either raise the age to cover the backlog or revisit the cap.
- Why not set the retry count to its maximum everywhere, to be safe?Each retry repeats the handler's side effects and adds load. For a non-idempotent handler that means duplicate charges or emails; for a struggling downstream it means more calls during the outage. Retries also cannot outlast a long outage. The safe default is a destination and a replay, with the count chosen per handler.
- The maximum event age only starts counting after the first failed attempt.
- An event keeps retrying until its retry count is used up, whatever its age.
- Raising the retry count is the way to survive a long downstream outage.
- Throttled asynchronous events are rejected at once, so they never age.
- Every handler should use the same retry count and event age.