Achieving Idempotency: There Are More Ways Than You Think

Mario Bittencourt
7 min readOct 16, 2023
Photo by Matt Hudson on Unsplash

Software development is a complex endeavor and one of the certainties is that as soon as you expose your application/system to real traffic and usage, it will face situations that don´t occur naturally during development.

Failures and concurrency are just two of these situations, and it is critical that you consider them as you design and implement.

If we consider just the failures, there are many areas you can work on to reduce the impact and duration, but it will never be 100% avoidable. Upon failure, a common approach taken is for the client to retry the request, but that on its own can bring additional issues, in the form of unwanted duplicate execution.

Let’s revisit the issue and its solution: making your application idempotent.

The Unavoidable Duplication?

To serve as context, I will present some failure scenarios our applications can face.

Figure 1. Execution took too long and despite being successful the client never gets the answer.

In this case, either due to concurrent load or the nature of the request (for example big payload), the time the service takes to perform the execution is longer than the client is willing to…

--

--