Real architecture · Mid
KVS: key-value as a platform product (642 million operations per minute)
A single "KV" becomes a family of services with different guarantees (Database, Cache, counters, Vault, QKVS). Teaches how to choose consistency per use case.
Short answer
A single "KV" becomes a family of services with different guarantees (Database, Cache, counters, Vault, QKVS). Teaches how to choose consistency per use case. Mercado Pago, the fintech arm of Mercado Libre, is an ecosystem of thousands of microservices that process financial transactions. One of the payment methods is account balance, the money the user keeps in the digital wallet.
01 · CONTEXT
The Mercado Pago digital wallet
Mercado Pago, the fintech arm of Mercado Libre, is an ecosystem of thousands of microservices that process financial transactions. One of the payment methods is account balance, the money the user keeps in the digital wallet.
Before debiting, the system must guarantee that there is a balance, in a naturally concurrent environment. That is why the critical path of these flows implements the TCC protocol (Try-Confirm/Cancel), with the amount reserved in a first step and the transfer in a later step.
The flow starts with the creation of the reservation: an amount is set aside for the transaction and, if this step fails, the transaction is aborted immediately.
With the reservation created, the user receives confirmation on the device, but the operation is not finished yet.
Later, another microservice releases the reservation, debits the source account, and credits the recipient in the same database transaction.
The company's relational database supports these and other critical services.
02 · THE PROBLEM
When the single database becomes the bottleneck
With ever heavier loads, the relational database became an obstacle to the wallet's horizontal scalability. The movements table, which holds the double-entry postings, grew eightfold in four years.
Growth went from about 12 TB in 2021 to about 100 TB at the end of 2024, with almost 700 million new rows per day. The team came within a few days of a hard limit: the table's tablespace was about to reach the maximum number of datafiles, and the situation was averted with an urgent migration to a partitioned table.
03 · BENCHMARK
How to choose the new database
The team evaluated three candidates in a benchmark that simulated the loads of the key services: a well-known NoSQL database and two newer NewSQL options.
| Candidato | What the benchmark recorded |
|---|---|
| Current relational | Outperformed the competitors in all benchmarks, but uses pessimistic locking that serializes transactions, and very active users call for extra strategies. |
| NewSQL, first option | Required significant architectural changes to handle concurrency. |
| NewSQL, second option | Brought specific primitives for contention, but other aspects, such as overall latency, were less attractive. |
| NoSQL | Stood out in performance, market maturity, and scalability, but without explicit locking, which forced the use of optimistic concurrency. |
The decision went to NoSQL, for its performance, its market presence, and the team's experience, relying on optimistic concurrency control because of the lack of explicit locking.
04 · MIGRATION
Two phases and two synchronized databases
The plan was split into two phases. Because it is a hypercritical service, the migration was done in stages. In the first, the reservation creation service was moved to the new storage, with the goal of increasing resilience to relational database degradation. In the final phase, the remaining services would be migrated.
The new reservation service operates exclusively on NoSQL. The challenge became keeping consistency between two stores, since account information would be distributed across both.
To synchronize, they used change data capture (CDC) on both databases, in both directions. They added two synchronization API calls: an asynchronous, best-effort one, triggered by each service to update balances, and another for when a service needs reservations that are not in the relational database.
Using features of the Fury platform, the team built an audit subsystem that records an event log for every API call, with the entity's before and after states in both databases, errors, and HTTP data. Fury was also used in the stress tests.
In the first phase, the new reservation service operates exclusively on the NoSQL database.
To keep the two databases consistent, change capture runs in both directions: what changes in one is passed on to the other.
The remaining services only migrate in the final phase; for when a service needs reservations that are not in the relational database, there is a synchronization call that guarantees the data immediately.
In the stress test, 30 TPS on one account, with items holding hundreds of pointers to reservations not yet replicated, were enough to generate hot-key throttling errors.
Preventive step: when detecting an account with at least 500 reservations not yet replicated to the relational database, the system triggers a best-effort synchronization.
Reactive step: upon hitting a throttling error, the account is temporarily blocked and the creation of new reservations pauses, to drain the item and resume safely.
05 · RESULTS
What the stress test showed
The test raised the payment volume on a single source account in steps of 1, 5, 10, 20, and 30 TPS, for three minutes each. Contention did not improve much when the synchronization stimuli were gradually turned off, which showed the need for an efficient synchronization strategy.
In the reviewed tests, there was an improvement of about 8% to 12% in the total reservations generated at each TPS level. In return, the new service saw an increase of about 33% in average response time.
According to the text, this trade brought much greater stability and predictability in the response time percentiles, something essential for a critical financial service. What remains is to fully redo the data model when moving off the relational database.
Frequently asked questions
What is KVS: key-value as a platform product (642 million operations per minute)?
A single "KV" becomes a family of services with different guarantees (Database, Cache, counters, Vault, QKVS). Teaches how to choose consistency per use case.
What does the KVS: key-value as a platform product (642 million operations per minute) design cover?
It is organized in these sections: The Mercado Pago digital wallet, When the single database becomes the bottleneck, How to choose the new database, Two phases and two synchronized databases, and What the stress test showed.
How long is KVS: key-value as a platform product (642 million operations per minute) and what level is it?
It takes about 15 minutes to read and is rated Mid 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.