Distributed

Lesson 03.2

Idempotency keys (API level)

An idempotency key is a unique id a client sends with a request so the server can recognise a retry and return the original result instead of doing the work again.

Asking again after no answer

Mia taps Buy ticket in the cinema app. The app sends request #7 to the cinema's computer. Ava or Ben, whoever is free, charges Mia's card $10 and sends back “Done!”.

Phones lose signal. If the app hears nothing for a while, it asks again. What could go wrong?

In this lesson you'll

  1. 1Watch a normal ticket purchase.
  2. 2Guess what happens when the answer gets lost.
  3. 3Find a rule so Mia pays once.