jzhao.xyz

Search IconIcon to open search

 .
  \_.
  /

Idempotence

Last updated May 5, 2022

How do we avoid cases where losing an ACK could lead to users doing an action multiple times (e.g. pressing the like button)?

Idempotence!

$f$ is idempotent if $f(x) = f(f(x))$

For example

Idempotent requests can be retried without deduplication.

However, this isn’t perfect when there are other actors/actions that intermix. For example, $f(f(x))= f(x)$ but $f(g(f(x))) \neq g(x)$ (e.g. liking, unliking, then liking is not the same as unliking!)

To somewhat fix this, use tombstones and record logical timestamp for when events happen


Interactive Graph