Background
Sometimes, in the process of using Redis, we can encounter problems, such as too much memory or full bandwidth. When we encounter these problems, we need to analyze the memory of Redis.
There are two kinds of memory analysis for Redis: online analysis and offline analysis. Online analysis directly connects to the Redis server and analyzes its memory, which will increase load on the Redis server. This may affect the stability of the Redis server. Offline analysis is based on RDB backup files, which will not affect the stability of the Redis server. This is recommended when the used memory is greater than 2GB.
How can we analyze Redis' memory offline? There are two well-known tools in the open source world that can help us: redis-rdb-tools and rdr.
redis-rdb-tools is implemented by Python, and rdr is implemented by Golang. If developers are not familiar with these two languages and want to expand some functions based on them, the process may be more difficult. Next, I will introduce another offline analysis tool implemented by c# that will be easier for c# developers to expand.
rdb-tools
rdb-tools is a tool to parse/analyze redis rdb files that is implemented by c#.
It consists of two parts:
- A parser library, that you can customize by yourself.
- An anslysis cli tool, that you can analyze some basic usages for command line.
The parser library is based on net6.0 so that we can easily expand it.
The cli tool is also based on net6.0, which is built using the command-line-api and can be packaged into binary files without runtime dependencies.
Usage of CLI tool
There are two ways to install rdb-cli.
- If you don't install .NET 6.0 SDK, download the tool from the latest stable release based on your OS version.
- If you have installed .NET 6.0 SDK, you can use
dotnet tool install --global rdb-clito install.
Here we will show the first way.
After downloading and extracting, you will get an executable file named rdb-cli.
Input ./rdb-cli -h to get the help information.

As you can see, there are two commands that we can use. The most important command is memory.

From the help information, you can see that you need to specify the RDB file and some specific options.
A simple and common example is as follows:
./rdb-cli memory /tmp/test/demo.rdb -ot html






Join the conversation! Your thoughts help the community grow.