In redis, select "number" gives access to specific database at that index. I my redis config it is set 16(why ?). We require high scaling of our application so what is the max limit for that?
The default number of Redis databases is 16, but can be configured to more. You probably have 16 in your config because of that default (see Storing Data with Redis).
Databases (in Redis) are a way to partition data logically (think "namespace", "key-space" or, in RDBMS terms, a schema). Redis databases have nothing to do with scalability, so your "max limit" question is out of context.
To scale you would want to do as Sergio suggests in his comment: create separate Redis instances/clusters for separate applications.
Answer: 1 Million (Maybe) or 100K on Linux (Maybe)
Official Info
So the official documentation indicates that the default setting is 16. This may be changed in redis.conf. The official documentation does not indicate the range that is allowed here.
Original Research
Through experimentation on my local Windows 10 WSL Debian install I found that I could set the conf value to anything and the server would start up fine.
However when I then attempted to select a database via command line my computer would freeze. I tried several values and the system worked perfectly and quickly at 1,000,000 (one million) and froze out at 10,000,000 (ten million). This number seems rather arbitrary in the computer world so either it is a memory limitation (seems unlikely but I don't know WSL's memory handling) or an arbitrary limitation set by the developers.
I ran some similar tests on my CentOS 7 Box and redis refused to start at 1 Million. But started fine at 100 thousand. No idea why it's different from my windows system or why it just refused to start instead of starting and then failing when a database was selected like my WSL version.
Disclaimer
As already stated by @kit in his previous answer databases are not designed for "scaling" but rather for "namespaces". For example a SAAS may run one code base but hundreds of clients each client with their own "namespace" or redis database. This allows you to flush a client without affecting others and minimize the administrative overhead. But running dozens of unique wordpress instances would be better suited for a unique install of redis each.
maxmemory-policy
–
Benedikt elasticahe
–
Benedikt The default number of databases in Redis is 16,index:0~15
。You can edit your redis.conf
file to adjust this number:
Steps:
1)edit config file
vi /etc/redis.conf
Default config path is
/etc/redis.conf
on Centos when installed with Yum.
2)find keyword:"databases"
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT <dbid> where
# dbid is a number between 0 and 'databases'-1
databases 16
databases 16:16 is the default on new installations
3)Update the number of databases:
databases 30
4)end,save and quit
The default number of databases is limited to 16. You can change it by making the changes in etc/redis/redis.conf file.
sudo vim etc/redis/redis.conf
change databases 16
to
databases 150
,you can type any number instead of 150.
Also, change supervised no
to
supervised systemd
in redis.conf file.
Restart redis:
sudo systemctl restart redis.service
Now try selecting any databases higher that 16.
redis-cli
select 34
Answer is "unlimited"... Here is the question and its answer from redis faqs page:
How many Redis databases can I create and manage?
The number of Redis databases is unlimited. The limiting factor is the available memory in the cluster, and the number of shards in the subscription.
Note the impact of the specific database configuration on the number of shards it consumes. For example: -Enabling database replication, without enabling database clustering, creates two shards: a master shard and a replica shard. -Enabling database clustering creates as many database shards as you configure. -Enabling both database replication and database clustering creates double the number of database shards you configure.
for mor details: https://redis.com/faqs/#:~:text=The%20number%20of%20Redis%20databases,of%20shards%20in%20the%20subscription.
© 2022 - 2024 — McMap. All rights reserved.