CodingSaves ~45 minutes

Implement retry logic with exponential backoff

Add battle-tested retry logic with jitter to any external service call in minutes.

The prompt

You are a resilience engineering expert. Implement a reusable retry utility in [LANGUAGE] with exponential backoff for resilient network and external service calls. The utility must: accept a configurable max retry count and initial delay, implement true exponential backoff (2^attempt * initialDelay), add jitter (full jitter algorithm) to prevent thundering herd, only retry on transient errors (configurable list of retryable error types or status codes), not retry on permanent errors (4xx excluding 429, business logic errors), honor Retry-After headers from 429 responses, log each retry attempt with attempt number and delay, and return a typed result on final failure. Include usage examples for HTTP calls and database operations.

Language: [LANGUAGE]
Use case: [HTTP CLIENT / DATABASE / QUEUE CONSUMER]

Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.

Want AI to fill this in for you?

Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.

Try it free →

More coding prompts