Chapter 3. Retries and Idempotency

‘Tis a lesson you should heed: Try, try, try again. If at first you don’t succeed, Try, try, try again

W. E. Hickson

When a call fails, trying again makes a lot of sense. When you fail to establish a connection, it’s possible your request just happened to be routed to a machine that was overloaded, or a machine that just got shut down for maintenance. Perhaps you hit a gateway at a point it was congested, or your request was routed to a server that was slow to start up. In many of these cases, simply trying again may well see the subsequent request routed to a machine that can serve the request promptly.

If you do decide to retry, there are still a host of questions to answer. How many times should you retry? Should you wait between retries? And are there situations where carrying out a retry can cause issues?

Before I answer those questions though, let’s start at the beginning. Does it always ...

Get Building Resilient Distributed Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.