Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory utilization in redis for each database

Redis allows storing data in 16 different 'databases' (0 to 15). Is there a way to get utilized memory & disk space per database. INFO command only lists number of keys per database.

like image 748
appanponn Avatar asked Nov 02 '12 02:11

appanponn


People also ask

Can Redis have multiple databases?

Redis comes with support for multiple databases, which is very similar to the concept in SQL databases. In SQL databases, such as MySQL, PostgreSQL, and Oracle, you can define a name for your databases. However, Redis databases are represented by numbers.

How do I find the size of my Redis database?

To get the size of a database in Redis, use the DBSIZE command. This returns the total number of keys stored in the currently selected database. The previous command returns the number of keys in the database at index 0. Another command you can use to get the database size is the info command.

Does Redis keep all data in memory?

All Redis data resides in memory, which enables low latency and high throughput data access. Unlike traditional databases, In-memory data stores don't require a trip to disk, reducing engine latency to microseconds.


1 Answers

No, you can not control each database individually. These "databases" are just for logical partitioning of your data.

What you can do (depends on your specific requirements and setup) is spin multiple redis instances, each one does a different task and each one has its own redis.conf file with a memory cap. Disk space can't be capped though, at least not in Redis level.

Side note: Bear in mind that the 16 database number is not hardcoded - you can set it in redis.conf.

like image 132
Ofer Zelig Avatar answered Sep 23 '22 19:09

Ofer Zelig