What is Idempotency?
Idempotency is a core design property of software systems where performing an operation multiple times produces the exact same result as running it once. In plain terms, it guarantees that if a command is accidentally repeated, the system behaves as if it only happened the first time. The server safely ignores any duplicate instructions while still confirming that the job was successfully done.
The Elevator Button Analogy
Imagine you are waiting in a lobby and press the button to call the elevator. The button lights up. If you get impatient and press that same button five more times, what happens? The elevator does not arrive any faster, and five different elevators do not suddenly descend to pick you up. The first press changed the state of the elevator system (it registered your call), and every subsequent press was safely ignored because the desired state had already been reached. The button is idempotent.
In contrast, think of a non-idempotent action like buying a snack from a vending machine. If you press the button for a bag of chips once, you get one bag. If you press it five times, you will be charged five times and receive five bags. In software, we want critical actions—like checking out of an online store—to behave like the elevator button, not the vending machine.






