Real architecture · Senior
Airbnb: preventing double payments (Orpheus)
Real production architecture. Key points: Idempotent Operations and Distributed Transactions.
Short answer
Real production architecture. Key points: Idempotent Operations and Distributed Transactions. Airbnb had been migrating its infrastructure to a service-oriented architecture (SOA). The source lists gains, such as developer specialization and faster iteration, and points out that, for billing and payments, it became harder to maintain data integrity.
01 · CONTEXT
Payments in a service-oriented architecture
Airbnb had been migrating its infrastructure to a service-oriented architecture (SOA). The source lists gains, such as developer specialization and faster iteration, and points out that, for billing and payments, it became harder to maintain data integrity.
An API call to a service that calls other downstream services, each changing state and possibly with side effects, amounts to running a complex distributed transaction.
A client makes an API call to a payments service.
That service makes other API calls to downstream services.
Each downstream service changes state and may have side effects.
Altogether, it amounts to running a complex distributed transaction.
02 · CONSISTENCY
Consistency when there is no single transaction
To ensure consistency across all services, the source mentions that protocols such as two-phase commit could be used. Without such a protocol, distributed transactions make it hard to maintain data integrity, allow graceful degradation, and achieve consistency.
Moreover, requests inevitably fail in distributed systems: connections drop and time out at some point, especially in transactions that bring together several network requests.
The source names three common techniques to achieve eventual consistency: read repair, write repair, and asynchronous repair.
| Technique | What the source says |
|---|---|
| Read repair | Cited as one of the three common techniques, with no detail in the public part of the article |
| Write repair | Each client write call to the server tries to repair an inconsistent state |
| Asynchronous repair | The server runs consistency checks, such as table scans, lambda functions, and cron jobs |
Asynchronous server-to-client notifications are also widely used in the payments industry to force consistency on the client side.
03 · THE CHOICE
Write repair and idempotency
The solution described in the post uses write repair: each client write call to the server tries to repair an inconsistent state. The source notes that write repair requires smarter clients.
The article's subtitle presents the result as a generic framework for idempotency, built to achieve eventual consistency and correctness in the payments microservices architecture.
An idempotent operation has the same effect whether it is executed once or several times.
In the write repair strategy, the client sends a write call to the server.
The service propagates the write to a downstream service, which changes state.
Connections drop and time out at some point, especially in transactions with several network requests.
Each client write call to the server tries to repair an inconsistent state.
Asynchronous checks run by the server act as a second line of defense.
04 · SOURCE LIMITS
What the public part covers
The page marks the article as a members-only story, and the public text breaks off right after stating that write repair requires smarter clients. This case is therefore limited to the problem and the consistency strategy presented in that part.
Frequently asked questions
What is Airbnb: preventing double payments (Orpheus)?
Real production architecture. Key points: Idempotent Operations and Distributed Transactions.
What does the Airbnb: preventing double payments (Orpheus) design cover?
It is organized in these sections: Payments in a service-oriented architecture, Consistency when there is no single transaction, Write repair and idempotency, and What the public part covers.
How long is Airbnb: preventing double payments (Orpheus) and what level is it?
It takes about 17 minutes to read and is rated Senior level.
Now design it yourself
Run this case as an interview in the System Design school: you make the decisions, the tutor challenges them and you see how your design scores.