Python Retry with Backoff — ELI5

You call a friend and they don’t pick up. What do you do?

You don’t call back immediately 100 times in a row — that would be annoying and they still probably can’t answer. Instead, you wait a minute, try again. If they still don’t answer, you wait five minutes. Then maybe thirty minutes. You give them time to become available.

That’s retry with backoff.

In software, your Python app talks to other services — databases, payment systems, weather APIs. Sometimes those services are temporarily busy or having a bad moment. Instead of giving up after one try, your app can retry.

But here’s the trick: each retry waits a little longer than the last.

  • First retry: wait 1 second
  • Second retry: wait 2 seconds
  • Third retry: wait 4 seconds
  • Fourth retry: wait 8 seconds

Why not just retry immediately every time? Because if a service is overloaded and a thousand apps all keep hammering it with instant retries, it never gets a chance to recover. It’s like everyone calling 911 at once — the lines stay jammed.

By backing off — waiting longer each time — you give the struggling service room to breathe and recover. Most of the time, a brief pause is all it needs.

The one thing to remember: Retry with backoff means “try again, but wait longer each time” — it gives struggling services breathing room to recover instead of piling on more requests.

pythonreliabilitypatterns

See Also