StreamShop Order Idempotency Keys

StreamShop Order Idempotency Keys #

To handle duplicate submissions or network issues we should idempotency keys to ensure orders are never duplicated. In StreamShop the order-api handles this.

The basic flow is:

  • order-api tries to reserve the key in Redis (SET NX, 1 hour TTL)
  • First request wins, creates the order, stores order_id on the key, returns 201
  • A later request with the same key finds the completed record and returns 200 with the original order
  • If the first request is still in progress, the retry gets 409

You can watch a short video showing this in action on YouTube