idempotency
idempotency: processing same request twice should have same effect as processing once
This is a term I have come across a few times over the course of my study. We can take financial transactions as an example to understand this.
Let's say you have to send a single withdrawal request for 50 bucks. However, behind the scenes, let's say there two attempts that occur, the second being another attempt because in the first attempt there was some situation - a failure or timeout. But this attempt however could re-start running.
If this happens, then at the end of the withdrawal request, 100$ should not be withdrawn accidentally. The reason why this doesn't happen is that the the second withdrawal could be prevented. One way to prevent this could be to incorporate something like a lookup in a withdrawal-processed table to see if the withdrawal has gone through.
We would check based on the ID of the transaction, and this is called an idempotency key.
If the first attempt did not go through, then it will not be logged in the table and then we can ensure that the first attempt was unsuccessful and why the second one will be allowed to process. If a retry with this ID appeared in the table, then it would mean that the first attempt was successful and the second attempt will simply just return the successful response from the first attempt. No matter the amount of retries, the same result should be shown.
In day to day life, this concept is similar to pressing an elevator button. If you press once or ten times, it will still bring you to your requested floor at the same time.