Redesign and Optimization of WeChat Pay Transaction Record System
The article presents a comprehensive case study of how WeChat Pay rebuilt its transaction record storage to handle massive data growth, improve performance, ensure data completeness, support flexible queries, and strengthen security through distributed key‑value storage, hierarchical partitioning, holiday traffic shaping, and strict access controls.
Background : Since the launch of WeChat Red Packets in 2013, the rapid popularity of social payments caused daily transaction records to reach 2 billion by the end of 2015, overwhelming the original key/value‑based storage system.
Problems of the old system : Single large value per user hit a 20 MB limit, transaction writes were on the payment critical path, record types were incomplete, and query UI required linear scrolling, making data retrieval inefficient.
Technical solution : The new design replaces the monolithic value with a distributed KV platform (tssd) that partitions user data into multiple values organized as a root node (metadata) and data nodes. Values are time‑segmented, forming a chain where the newest segment is at the head; recent data requires only two lookups, while older data can be found via binary search (O(log n)).
Classification and statistics : Because data is stored chronologically, category and aggregation queries are performed by scanning the relevant time window (average 800 records per user, typically a month), with monthly statistics cached and current‑month stats computed in real time.
Online operation : To handle holiday spikes (e.g., Chinese New Year, 5.20, 11.11) the system buffers excess requests on the gateway’s local disk and drains them later, applying this throttling only to red‑packet traffic.
Data security : Three layers protect user data – ticket‑based access control with whitelist servers, field‑level masking/encryption and ID virtualization, and strict personnel policies with minimal privileges, audit logs, and centralized permission management.
Effects : After reconstruction, data completeness and accuracy improved dramatically, complaint rate dropped 67 %, daily transaction records now approach tens of billions (including red packets), total stored records exceed one trillion, and query experience is much smoother.
Conclusion : The rebuilt transaction record system provides a scalable, reliable, and secure foundation for WeChat Pay, ready to evolve with future payment scenarios and continue delivering a seamless user experience.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
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.