.NET Architecture & System Design Interview Question #126
What is the Retry pattern?
Resilience, Rate Limiting, Health Checks & Observability Senior Advanced
Quick Interview Answer
The Retry pattern repeats an operation after a transient failure when there is a reasonable chance that a later attempt will succeed. Examples include temporary network errors, throttling, or a briefly unavailable dependency.
Detailed Explanation
The Retry pattern repeats an operation after a transient failure when there is a reasonable chance that a later attempt will succeed. Examples include temporary network errors, throttling, or a briefly unavailable dependency.
Retries should be bounded and normally use delay or exponential backoff. They should only be applied when the operation is safe to retry, because repeating a non-idempotent operation can create duplicate effects.
Code Example
try
{
return await CallDependencyAsync();
}
catch (TransientException)
{
await Task.Delay(backoff, token);
// retry within a bounded policy
}