Stripe: Idempotency in APIs
Transcription of handwritten notes on network failures and idempotency.
Source reference: [1]
Source: stripe.com
idempotency in APIs#
So The blog discuss Network failure in which The main ones are:
- Connection may initially fails meaning That either a probleme in The client or a probleme at The client's network in which The client can't connect to The server.
- A midway call fail meaning That The failure may happen in a middle server and not reaching The server.
- A server That received The call but didn't respond due some failure or more like The connection broke before The server can tell it client about it.
So Those failure may lead to some inaccuracy Problemes example of a client charged twice or an operation That didn't Tell its client about The result which made it confused or lead to some kind of ambiguity, not just inaccurate but also introduce safety problemes.
So it's a common probleme in distributed systems.
Making liberal use of idempotancy#
So in order to address Those failures The solution is to implement endpoints That are idempotent. So when a client sees any kind of error it can know That it can Keep trying safely.
So in short The probleme is solved by idempotancy keys which are identifiers That are tied to Transaction or events uniquely sent with the requests in which The server can safely [illegible] if it's done if it's not... Then return The accurate response and also along with The exponential backoff in which The delays between The retries is exponential because of reasons such as a down time server in which a client Keep retrying is like hammering and will contribute in That downtime.
So The design should make sure:
- The failures handled consistently is having clients retry connections operations against remote services. because not doing so could lead to data in a inconsistent state.
- The failures handled safely by idempotency and The use of idempotency keys to make unique passing unique value and retry request as needed.
- The failures handled responsibly by making sure clients are using exponential backoff and random jitter to not Keep hammering strached servers.
References
- 1Designing robust and predictable APIs with idempotencyBrandur Leach · 2017