RDR: An Open-Source Tool for Visualizing and Analyzing Redis Memory Usage
This article introduces RDR, an open-source visualization platform developed by Xueqiu's SRE team to safely and efficiently analyze Redis memory consumption by parsing RDB files, estimating key-level memory usage based on internal data structures, and generating intuitive statistical reports for operational optimization.
Operating Redis at scale often leads to unpredictable memory consumption due to unrestricted data storage practices by developers, making it difficult for SRE teams to identify memory-heavy keys and optimize resource allocation. To address this, Xueqiu's SRE team developed RDR (Redis Data Reveal), an open-source visualization platform designed to safely and efficiently analyze Redis memory usage.
The design process evaluated three data extraction methods: using the keys * command, parsing AOF files, and generating RDB snapshots via bgsave. After weighing performance and safety, the team selected bgsave on replica nodes during off-peak hours to generate daily RDB files, ensuring minimal impact on production services while maintaining acceptable data freshness.
The core implementation involves parsing the RDB file to extract keys and values, then estimating memory consumption based on Redis internal data structures such as dictEntry, robj, sds, and quicklist. The calculation accounts for structural overhead, TTL storage, memory alignment, and jemalloc allocation strategies, providing a highly accurate approximation of actual memory footprint.
For statistical analysis, the system employs a min-heap to track the top N largest keys, aggregates memory usage by data type, and categorizes keys by normalized prefixes to map resource consumption to specific business modules. This approach transforms Redis memory management from a black box into a transparent, data-driven process.
Since its deployment, RDR has significantly improved Redis resource optimization, reduced infrastructure costs, and empowered developers to self-monitor their services. The tool has been open-sourced to benefit the broader community, with the repository available on GitHub for further contribution and adaptation.
Snowball Engineer Team
Proactivity, efficiency, professionalism, and empathy are the core values of the Snowball Engineer Team; curiosity, passion, and sharing of technology drive their continuous progress.
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.