Adyen System Design
Adyen-scale payment acceptance: a stateless edge and a provable ledger
By Ankur NayakReviewed
How a global payments platform keeps accepting payments even when its central systems are down: a stateless acceptance layer stores each payment locally and forwards it later, while a double-entry accounting system on sharded PostgreSQL proves every record adds up to zero.
Open in Studio· edit a copy- Throughput
- 5,000+ PostgreSQL transactions/s (2018)
- Storage
- Largest cluster 74 TB (2018)
- Processed volume
- €803.8B
- Accounting rows per payment
- ~50
- Database replicas
- Primary + 3+
Requirements
Functional
- Accept payments from shoppers and merchants worldwide
- Process each payment exactly once, even when it is retried
- Book every payment in double-entry accounting
- Reconcile with partners' files and pay merchants out
- Produce reports for merchants
Non-functional
- Keep accepting payments when central systems are unavailable
- Never lose an accepted payment
- Scale acceptance by adding machines
- Upgrade very large databases without stopping payments
In depth
Built for the day something breaks
Adyen processes payments for large merchants worldwide: €803.8 billion in the first half of 2026 alone. Its engineering team has been unusually open about how the platform is put together, in a 2021 series called Design to Duty and earlier posts on running PostgreSQL. The recurring theme is a choice most payment systems face: when something central is unavailable, do you stop taking payments or keep going and reconcile later? Adyen chose to keep going, and built the architecture around that.
A stateless front door
Every payment enters through the Payments Acceptance Layer (PAL). It holds no state of its own: changes are processed asynchronously, so PAL instances can be shut down or added without affecting payments. That makes scaling linear: if one PAL handles X payments a second, two handle 2X. Adyen says this mechanism has been essentially unchanged since the company started.
There is a security rule baked in too: externally exposed systems may not write to central databases. The PAL can't reach into accounting, so a compromised or misbehaving edge host has limited reach.
To recognise retried payments, Adyen integrated CockroachDB, a distributed database, with the PALs, so the information needed for idempotency is available locally rather than in a central store.
Accept now, account later
If the PAL can't write to central databases, how do payments reach accounting? Each PAL saves the payment to a local database queue (PostgreSQL), and a separate process forwards it to accounting when possible. Because the queue lives on disk rather than in memory, a PAL crash doesn't lose payments. This is the outbox idea applied at the edge: record durably first, deliver asynchronously.
The trade-off is explicit: accounting and reports can lag behind acceptance, but shoppers can still pay while central systems are being repaired or upgraded.
Accounting that has to sum to zero
Adyen's accounting system is built on double-entry bookkeeping, written in-house and also used for its banking platform. Services can't write arbitrary rows: records are added only through templates that are mathematically verified to balance, and the check runs automatically on every template change. The invariant is simple to state and to test: the sum of all accounting records is always zero.
It is also a lot of rows. Over its lifetime a single payment inserts about 50 records, and at thousands of inserts a second the single PostgreSQL accounting database started to strain. Adyen sharded accounting into several clusters, routing round-robin with adjustable weights rather than by business domain, which would have reduced flexibility. The cost shows up elsewhere: partner reconciliation now parses each file and splits it per cluster, and payouts that span clusters need messages back and forth.
Running very large PostgreSQL
The transactional databases total hundreds of terabytes, all on PostgreSQL. A 2018 post describes clusters with a primary and at least three replicas across data centres, more than 5,000 transactions per second, and a largest cluster of 74 TB. Upgrading a database that size without downtime relies on the same principle as the PAL: the software can pause and queue traffic to a cluster without affecting payment acceptance. The upgrade itself uses storage snapshots, and access resumes only once at least two replicas are online and in sync. A failed upgrade can roll back to the pre-upgrade snapshot, losing time but not data.
Reporting and analytics
Merchant reports come from a custom streaming framework in Java on PostgreSQL. It was built instead of using Kafka because, at the time, Kafka didn't support exactly-once delivery; Adyen has since discussed scaling it up or replacing it with Kafka. Analytics runs on a Spark and Hadoop cluster orchestrated by Airflow.
When things fail
Adyen's two documented failure stories both come back to the same principle: queue rather than reject.
- Accounting is unavailable. The acceptance layer doesn't depend on it. Each payment is written to the PAL's durable local queue, and the forwarding process retries until accounting confirms. Shoppers notice nothing; balances and reports simply update later. Adyen describes this as choosing to keep accepting payments over waiting for consistency.
- An accounting database is upgraded. Traffic to the cluster is paused and queued, the primary is upgraded in place, a storage snapshot is copied to the replicas, and access resumes only once at least two replicas are online and in sync. If anything goes wrong, the cluster rolls back to the pre-upgrade snapshot. In 2018 the whole process took around a day per cluster, with no effect on payment acceptance.
The trade-offs
- Accept now, account later. Payments keep flowing while central systems are down, and the edge scales linearly. The cost is that balances and reports lag behind acceptance, and every acceptance host runs a local queue that has to be operated and monitored.
- Round-robin sharding of accounting. Spreading records across PostgreSQL clusters by weight, rather than by merchant or business domain, keeps load even and makes rebalancing a matter of adjusting weights. The price is cross-cluster work: reconciliation files are split per cluster, and payouts that span clusters need messages between them.
- A custom streaming framework. Building reporting streams on PostgreSQL gave exactly-once processing when Kafka didn't support it, with one database technology to run. It also means in-house software to maintain, which is why Adyen has discussed moving to Kafka.
What's not public
The posts don't describe where fraud screening runs or how Adyen connects to card networks and acquirers, so those parts of the diagram are marked as inferred.
What to take into an interview
- Decide what must keep working when central systems fail, and design the edge around it
- Make the edge stateless and keep it away from central databases
- Queue durably at the edge, then deliver asynchronously and idempotently
- Constrain ledger writes to verified templates and test the zero-sum invariant
- Shard ledgers for write volume, and plan for the cross-shard work it creates
Components
Shopper
Client. Pays online or in person.
Merchant Systems
Service. Send payments to Adyen through its API and receive the results.
Payments Acceptance Layer
Java, statelessAPI gateway. Every payment enters through the PAL. It holds no state of its own, so instances can be added or removed freely, and it is not allowed to write to the central databases.
Why: Statelessness makes scaling linear: one PAL handles X payments a second, two handle 2X. Keeping the edge away from central databases limits what an exposed system can touch.
Idempotency Store
CockroachDBSQL database. A distributed database integrated with the PALs so payment information is available locally to recognise retries.
Building block: Idempotency Keys
Risk Checks
inferredML model. Fraud screening before authorisation. Adyen's architecture posts don't describe where this runs.
Card Networks & Banks
inferredExternal API. Authorise and settle payments.
Local Payment Queue
PostgreSQLSQL database. The PAL saves each payment to a local database; a separate process picks it up and forwards it when accounting is available.
Why: The queue is on disk, not in memory, so no accepted payment is lost if a PAL crashes or the central systems are down.
Building block: Saga & Transactional Outbox
Accounting System
Service. In-house double-entry framework, also used for Adyen's banking platform. Records can only be added through mathematically verified templates.
Building block: Double-Entry Ledger
Payment Event
Service. A payment forwarded from the acceptance layer's queue.
Booking Templates
Service. Every record is written through a template that is verified to balance, checked automatically on every change.
Cluster Routing
Service. Round-robin across accounting clusters, with adjustable weights.
Building block: Database Sharding
Accounting Clusters
PostgreSQLSQL database. The accounting database, sharded into several clusters.
Reconciliation
Worker. Parses each partner file, then splits it per cluster to match records.
Payouts
Service. Pays merchants; payouts spanning clusters need messages back and forth.
Accounting Database
PostgreSQL clustersSQL database. Sharded into several clusters, each with a primary and at least three replicas across data centres.
Building block: Database Sharding, Replication
Reporting
Custom streaming on PostgreSQLWorker. A Java streaming framework built on PostgreSQL rather than Kafka, chosen when Kafka didn't yet support exactly-once delivery.
Analytics
Spark, AirflowBatch processing. A Spark and Hadoop cluster orchestrated with Airflow.
Merchant Dashboard & Reports
Client. Where merchants see settlement, payout and transaction reports.
Request flows
Accept a payment
- The shopper pays; the request reaches any instance of the stateless acceptance layer.
- The PAL checks the local idempotency store so a retried payment isn't processed twice.
- The payment is screened for fraud (where this runs isn't described publicly).
- The card is authorised by the network and the issuing bank.
- The PAL saves the payment to its local database queue; it never writes to central databases.
- The shopper gets the result straight away; accounting happens later.
- A separate process forwards the payment to accounting when it can.
- Verified templates write balanced records to one of the accounting clusters.
A merchant's report is produced
- The reporting framework streams new accounting records from PostgreSQL.
- Merchants receive reports built from the same records that balance to zero.
Failure scenarios
What if: accounting is unavailable?
The acceptance layer doesn't depend on accounting being up. Each payment is saved to the PAL's local database queue, and a separate process forwards it when accounting is reachable again. Adyen describes this as choosing to keep accepting payments over waiting for consistency.
User impact: None for shoppers; balances and reports update late.
- Durable local queue in PostgreSQL, not memory
- Forwarding retries until accounting confirms
What if: an accounting database is upgraded?
To upgrade PostgreSQL, traffic to the cluster is paused and queued, the primary is upgraded in place, and a storage snapshot is copied to the replicas. Access resumes only when at least two replicas are online and up to date. If something goes wrong, the cluster rolls back to the pre-upgrade snapshot.
User impact: None for payment acceptance; the whole upgrade took around a day per cluster in 2018.
- Queue traffic instead of rejecting it
- Snapshot-based upgrade with rollback
- Require two in-sync replicas before reopening
Trade-offs
Accept now, account later
The acceptance layer stores payments locally and forwards them to accounting asynchronously.
- Pros
- Payments keep flowing when central systems are down
- The edge scales linearly
- Cons
- Balances and reports lag behind acceptance
- A local queue on every acceptance host to operate
Round-robin sharding of accounting
Spread accounting records across PostgreSQL clusters round-robin instead of by business domain.
- Pros
- Even load and easy rebalancing by adjusting weights
- Cons
- Reconciliation and payouts must work across clusters
Alternatives: Sharding by merchant or account
A custom streaming framework on PostgreSQL
Build reporting streams on PostgreSQL instead of Kafka.
- Pros
- Exactly-once processing when Kafka didn't support it
- One database technology to run
- Cons
- In-house software to maintain; Adyen has discussed replacing it with Kafka
Frequently asked questions
How does Adyen keep accepting payments when a central system is down?
Its Payments Acceptance Layer is stateless and never writes to central databases. Each payment is saved to a local database queue on the acceptance side, and a separate process forwards it to accounting once accounting is available, so no accepted payment is lost.
What database does Adyen use for accounting?
PostgreSQL. The accounting database was sharded into several clusters, each with a primary and at least three replicas across data centres; in 2018 Adyen reported over 5,000 transactions per second and a largest cluster of 74 TB.
How does Adyen make sure its accounting is correct?
It uses double-entry bookkeeping written only through templates that are mathematically verified, so the sum of all accounting records is always zero. The verification runs automatically whenever a template changes.