learning-it by example

Back to the video

Retry a Flaky API Without Duplicates: Idempotency Keys

A plain retry loop put five duplicate orders into a stand-in system. One key fixed it.

Video #305 ยท Forward deployed engineer interviews

Steps in the video

  1. 0:00 A plain retry loop put five duplicate orders into a stand in system
  2. 0:38 The idea
  3. 1:15 Setup
  4. 1:41 The flaky ERP
  5. 2:08 Push, one order at a time
  6. 2:32 Three ways to call it
  7. 2:51 Count what it holds
  8. 3:40 What this does not show
  9. 4:11 Mistakes to avoid
  10. 4:36 My take and next steps
  11. 5:05 Recap

Files

  • erp.py (22 lines)
  • run.py (14 lines)
  • sync.py (30 lines)

Download the code (zip)

Tested with

Python 3.12.15

What this does not show

The ERP is a stand-in class with a fixed failure pattern, not a real system. No network, no queue, and nothing survives a restart. The key only helps if the other system honours it.

Sources

Learning IT by Example.