Redis memory usage for each database

Redis allows you to store data in 16 different "databases" (from 0 to 15). Is there a way to get the used memory and disk space for each database. The INFO command contains only a list of keys for each database.

+6
source share
3 answers

See redis-rdb-tools

You can get approximate memory usage in the database, it should be within 10% of reality.

+4
source

No, you cannot control each database individually. These "databases" are intended only for the logical partitioning of your data.

What you can do (depending on your specific requirements and settings) are several instances of redis, each of which performs a different task, and each of them has its own redis.conf file with a memory cover. Disk space cannot be limited, although at least not at the Redis level.

Note: remember that database number 16 is not hard-coded - you can set it in redis.conf .

+2
source

I did this by calling dump on all keys in Redis DB and measuring the total number of bytes used. This will slow down your server and take some time. It seems that the dump size returns about 4 times less than the actual memory usage. These numbers will give you an idea of ​​which db uses the most space.

Here is my code: https://gist.github.com/mathieulongtin/fa2efceb7b546cbb6626ee899e2cfa0b

0
source

All Articles