Maxwell High‑Performance Accounting Database: Architecture, Performance, and Real‑World Deployment at Alipay
The article presents Maxwell, a C/assembly‑based high‑performance accounting database designed for Alipay, detailing its architecture, hotspot account challenges, performance optimizations such as Raft and a custom storage engine, and real‑world results showing thousand‑fold throughput gains and robust operation during massive promotional events.
Alipay's most critical system is accounting, where accuracy, timeliness, and throughput directly affect payment experience and fund safety; the accounting database forms the performance foundation for the entire payment business.
Maxwell accounting database is a highly optimized hardware‑software solution whose core is written entirely in C and assembly, with no third‑party library dependencies, offering extreme controllability.
This article uses Ant Group's hotspot accounting problems as a case study to share the outcomes of developing the Maxwell high‑performance accounting database and its deployment.
Hotspot accounts generate massive inbound/outbound fund requests over short or extended periods, commonly seen in large merchant scenarios such as live‑stream sales, promotional events, and can cause payment experience degradation or system-wide failures if not handled properly.
Typical mitigation techniques—buffering, aggregation, splitting, throttling, or non‑real‑time accounting—alleviate pressure but introduce issues like overdraft risk, delayed balance updates, high operational cost, and costly recovery.
Therefore, a hotspot accounting system must provide high reliability, high throughput without complex tricks, low latency, low jitter, no performance knee‑points, transactional guarantees, and linear scalability with added resources.
After extensive research, a custom solution was built from scratch. The architecture consists of a client sending accounting requests to a processing cluster; each cluster contains three workers, and each worker comprises three core modules: Raft for multi‑replica consistency, accounting logic handling ACID‑like data processing, and the Maxwell storage engine for data persistence.
Key advantages of Maxwell include full‑stack optimization aligned with hardware characteristics, logic proximity to data, SSD‑optimized storage engine eliminating read‑write amplification, million‑level parallel transaction capability, built‑in cache and network management modules, a user‑space file system based on SPDK, reduced lock contention, and an adaptive Raft (ARaft) that maintains stable throughput and latency under varying loads.
Performance tests show ARaft achieving 9.1× higher throughput than a popular open‑source Raft implementation while keeping latency constant; images illustrate these results.
Storage engine comparisons reveal RocksDB’s throughput fluctuating between 10k‑40k TPS with latency spikes up to 1200 ms, whereas Maxwell’s engine maintains a stable 20k TPS with an average latency of 3 ms; corresponding charts are included.
In summary, Maxwell is a fully C/assembly‑implemented accounting database delivering ultra‑high throughput, stable performance, and low resource consumption, enabling Alipay to provide reliable, low‑latency payment services while dramatically reducing hardware and operational costs.
The system has withstood the Double‑11 shopping festival, scaling from thousands to hundreds of millions of accounts and supporting diverse business lines such as e‑commerce, finance, travel, and marketing, delivering billions of yuan in cost savings.
Additional scenarios include micro‑loan risk control (10× performance boost, 10× resource reduction), financial time‑series storage (70 k rows/s write, 9 k rows/s random write on a single 17‑core instance), and asset‑pool valuation (1200× faster real‑time valuation with 1/6 hardware usage).
Looking forward, Maxwell’s standardized solution is being rolled out across the entire platform, covering core services like main accounts, internal accounting, and large fund accounts, while new business areas such as domestic red‑packet marketing are being explored.
Author: Ma Ling, head of Ant Group’s High‑Performance Computing team, holder of 35 patents (including 12 US patents) in CPU architecture, distributed storage, and blockchain; contributor of widely used glibc assembly routines; leader of the Maxwell accounting database project that achieved 100‑1200× performance improvements.
AntTech
Technology is the core driver of Ant's future creation.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.