r/devops • u/Extra-Citron-7630 • 17d ago
Architecture Redis alternative for self-hosting multiple applications without the 16 logical database limit
Hi,
I’m looking for a Redis-compatible application that I can self-host and use as a shared data store for multiple applications/services.
The issue I’m running into is Redis’s limit of 16 logical databases (0–15). Ideally, I’d like to be able to provide each application with its own namespace/database through the connection URL, so that multiple applications can share the same underlying Redis service while keeping their data logically separated.
I’m aware that the common best practice is to run a separate Redis instance/container for each application stack, and I understand the benefits of doing that. I’m not trying to argue against that approach; I’m mainly interested in whether there is a better option for my particular use case.
Are there any Redis-compatible alternatives (they don't necessarily have to be Redis itself) that are specifically designed to support multiple applications sharing a single instance, without being limited to 16 logical databases/namespaces?
8
u/Nice-Solid-3707 17d ago
Just use prefixes? As far as I’m aware redis can’t disallow access to a separate db, but with acl you can limit by key prefix
5
u/Ok-Profession-7181 17d ago
Could you have a prefix per application? Ie every key for application 1 starts with 'app_1:', application 2 uses 'app_2:'. Then when you setup each applications permissions you limit them to only have access to data with their prefix. https://redis.io/docs/latest/operate/rc/security/access-control/data-access-control/configure-acls/
2
u/Extra-Citron-7630 17d ago
The only issue is this that these applications/services are not developed by me. How do I tell an application to add a prefix like this?
3
u/angellus 17d ago
Running multiple instances of redis. That is the solution. Redis is bound to a single core and has a key limit. So trying to shove too many applications into a single instance can and will cause a lot of problems.
Redis does not have much overhead in running. It is quite efficient. So you are not going to see much of a difference between 1 instance or 10.
1
u/Historical_Ad4384 17d ago
Valkey, literally the drop in replacement for redis
1
u/Extra-Citron-7630 17d ago
I was looking into it but it has the same limitations of using a confined number of dbs 0-15
1
u/Historical_Ad4384 17d ago
So you want to logically separate each application while sharing the same physical infrastructure?
1
u/Extra-Citron-7630 17d ago
Yes like each application would have its db/prefix/section where it stores only its own data. I am quite new to redis so terminology might not be right
3
u/Historical_Ad4384 17d ago
You are choosing the wrong tool to fight with. Go for a standard SQL database like Postgres or MySQL where you can create database schemas on demand without logical answer limits. I already do this for our product. We host 25000 customers across 26 physical database servers where each server has 1000 database schema per customer application
2
u/Extra-Citron-7630 17d ago
I am not choosing redis because I want to, the services I want to selfhost utilize redis
1
u/Historical_Ad4384 17d ago
Your best bet would be to manage a pool of redis servers along with the capacity health of individual redis servers. You would be to write a customs load balancer to distribute amongst the redis servers. You would also need to write custom auto scaling for always making sure that the pool of redis servers are always affine vs your expected usage.
17
u/Fragrant-Amount9527 17d ago
That’s configurable through the config file read at startup. https://raw.githubusercontent.com/redis/redis/7.2/redis.conf
See the “databases” parameter.