Operations 11 min read

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

This article chronicles the evolution of WeChat Pay’s transaction record system—from early key/value storage bottlenecks and incomplete data to a distributed, tiered architecture that supports billions of daily records, improves query performance, ensures data security, and handles holiday traffic spikes through flexible throttling.

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

Background

WeChat Red Packet launched in 2013 and quickly became a social payment phenomenon, driving massive growth in WeChat Pay. By the end of 2015 the daily transaction record volume reached 2 billion, overwhelming the original key/value storage system.

Problems of the Old System

Data were stored as a single value per user; the 20 MB limit caused write failures as data grew. Transaction writes were placed on the payment critical path, slowing the user experience. Record types were incomplete (e.g., missing red‑packet receipts), and queries were limited to linear scrolling, making specific look‑ups cumbersome.

Technical Solution

Rather than a monolithic relational database, a distributed key‑value store (tssd) with tiered value management was adopted. User data are split into multiple values: a root node holds metadata and several data nodes hold the actual records. Data are partitioned by time, and root nodes are linked in a chain so recent data reside near the head. Queries need at most two lookups for recent data and O(log n) for older data.

Classification and statistics are performed by scanning the time‑range data (average 800 records per user per month) and caching monthly aggregates.

Online Operations

Historical data migration required consolidating incomplete records from multiple sources, taking six months to clean and import 72.3 billion records.

Data anomalies caused by storage timeouts were mitigated by a full‑link queuing mechanism to avoid write‑overwrites.

Holiday traffic spikes (up to ten times normal) are smoothed by buffering excess requests on the gateway’s local disk and replaying them later; this throttling is applied only to red‑packet requests.

Security measures include ticket‑based access control, data masking/encryption of sensitive fields, and strict personnel policies with minimal privileges and audit logs.

Effect

After reconstruction, data completeness and accuracy improved dramatically, complaint rate dropped 67 %, daily transaction records now approach tens of billions (including red packets), total data exceeds one trillion, and query experience is much better.

Conclusion

The rebuilt system provides a scalable, reliable, and secure platform for user transaction records, ready for future payment scenarios and continuous enhancements.

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 Systemshigh availabilityscalable architecturedata securityWeChat Paytransaction 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.