How We Scaled WeChat Pay’s Transaction Records to Billions Daily

This article details the challenges of WeChat Pay’s original transaction‑record system, the architectural redesign using distributed key‑value storage and data partitioning, and the resulting improvements in scalability, reliability, security, and user experience.

21CTO
21CTO
21CTO
How We Scaled WeChat Pay’s Transaction Records to Billions Daily

Problems with the Old System

The original transaction‑record storage used a simple key/value model where each user’s entire transaction history was stored in a single value; as data grew, values exceeded the 20 MB limit, causing write failures. Moreover, writing transaction records was on the payment critical path, the record types were incomplete, and query mechanisms were primitive, forcing users to scroll endlessly.

Historical Red Packet Volume
Historical Red Packet Volume

Technical Solution

To support massive data volume with high performance and reliability, a distributed KV storage platform (tssd) was adopted and enhanced with a multi‑level data‑partitioning scheme. User data is split into several values: a root node storing metadata and multiple data nodes holding actual records. Data is partitioned by time, enabling fast page queries and binary‑search‑style lookup for specific timestamps.

User Data Storage Diagram
User Data Storage Diagram
Data Partition Organization Diagram
Data Partition Organization Diagram

Online Operations

Historical data migration required consolidating incomplete records from multiple sources, taking six months to clean, verify, and import 72.3 billion rows. To handle storage platform timeouts that caused occasional data loss, a full‑link queuing mechanism was introduced, ensuring each user’s requests are processed on the same server and process to avoid overwrites.

Data Overwrite Illustration
Data Overwrite Illustration

During holiday peaks (e.g., Chinese New Year), request volume can be ten times normal. A flexible throttling strategy buffers excess requests to local disks and later drains them to storage, applied only to red‑packet traffic to preserve resources for other payment types.

Holiday Peak Comparison
Holiday Peak Comparison

Data Security

Three layers protect user data: (1) access control with tickets and whitelist for internal services; (2) data masking and encryption of sensitive fields (WeChat ID, UIN, merchant ID) plus ID virtualization; (3) strict personnel policies, minimal permissions, centralized privileged‑access management, and comprehensive operation logging for audit.

Effect

The rebuilt system dramatically improved data completeness and accuracy, eliminating complaints about missing transaction details and reducing overall complaint rate by 67 %. Daily transaction records now approach tens of billions (including red packets), total stored data exceeds one trillion records, and query experience is much smoother.

New Transaction Record System UI
New Transaction Record System UI

Conclusion

WeChat Pay’s transaction‑record system redesign showcases how distributed KV storage, time‑based data partitioning, flexible throttling, and rigorous security measures can scale a payment platform to handle billions of daily records while delivering a reliable, secure, and user‑friendly experience.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed KVWeChat PayData Partitioningtransaction storage
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.