Distribute maxmemory between databases.

47 views
Skip to first unread message

Vadim Dzyuban

unread,
Jun 15, 2016, 3:41:51 AM6/15/16
to Redis DB
I setup "maxmemory 3Gb" in redis.conf file. Now I'd like to distribute that 3Gb between 4 databases as follows: db0 - 1Gb, db1 - 0.5Gb, db2 - 0.5Gb, db3 - 1Gb.
Is there any way to do it ?
Thanks in advance.

Itamar Haber

unread,
Jun 15, 2016, 3:48:49 AM6/15/16
to Redis DB

Hello Vadim,

Redis' databases are more like different namespaces than actual separate entities. As such, all databases in the same Redis instance share the configuration settings, `maxmemory` included (but also persistence, eviction, and all the rest).

The way to achieve what you're after is to install 4 separate Redis servers - each with its own settings.

Itamar

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

Vadim Dzyuban

unread,
Jun 15, 2016, 10:42:40 PM6/15/16
to Redis DB
You're right Itamar, that all databases share one config file. But I think databases are treated as separate entities. To prove that I would refer to the redis-cli 'select <db_number>' to switch from one db to another. Also, there is redis-cli command 'migrate key' from one db to another which referenced db as an integer number. That is redis-cli commands refer to the databases as to the entities. I think, it might be more effective to setup multiple config files somehow (not sure how to do it) - one per database, rather than setup multiple redis servers with only one db in each server in my particular use case.
Thank you for the response Itamar.

Matt Palmer

unread,
Jun 16, 2016, 12:40:48 AM6/16/16
to redi...@googlegroups.com
On Wed, Jun 15, 2016 at 07:42:40PM -0700, Vadim Dzyuban wrote:
> You're right Itamar, that all databases share one config file. But I think
> databases are treated as separate entities.

No, they're treated as separate namespaces.

> To prove that I would refer to
> the redis-cli 'select <db_number>' to switch from one db to another.

That changes the namespace being acted upon.

> Also, there is redis-cli command 'migrate key' from one db to another
> which referenced db as an integer number.

That is moving a key from one namespace to another.

> That is redis-cli commands
> refer to the databases as to the entities.

Yes, it is referring to the namespace as an entity.

> I think, it might be more
> effective to setup multiple config files somehow (not sure how to do it) -
> one per database

You can't do that. A config file operates on a Redis instance, not on a
single database namespace within that instance.

> rather than setup multiple redis servers with only one
> db in each server in my particular use case.

No, it wouldn't. Setup multiple Redis instances and move on with your day.

- Matt

Reply all
Reply to author
Forward
0 new messages