Skip to content

Multi tenant client to serve serverless usecases. #34

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
srikar-jilugu opened this issue Mar 13, 2025 · 5 comments
Open

Multi tenant client to serve serverless usecases. #34

srikar-jilugu opened this issue Mar 13, 2025 · 5 comments

Comments

@srikar-jilugu
Copy link
Contributor

We have a use case where we need to connect to multiple serverless Redis/Valkey caches (e.g., AWS ElastiCache Serverless) dynamically. However, current valkey/redis clients are designed to interact with a single cluster, requiring periodic topology updates, which makes them incompatible with multi-tenant scenarios.

With the introduction of serverless offerings, a stateless client that can dynamically route commands among multiple endpoints without any need to maintain cluster state could better serve the usecases Most existing clients assume a single cluster and require ongoing topology updates, which aren't required for serverless caches(ref)

Why Not Use Multiple Clients?

  • This is a feasible solution, but it requires us to maintain the set of hosts as to initialise the clients during startup and maintaining multiple clients is memory heavy

Feature Request

A lightweight, stateless valkey client that:

  • Can maintain independent connection pools for multiple endpoints and dynamically routes commands
  • wouldn't require it to keep track of cluster topology and handle routing to replicas.

Is there any ongoing work or plans for something like this? Would love to discuss possible approaches!

@rueian
Copy link
Collaborator

rueian commented Mar 13, 2025

Hi @srikar-jilugu, I don’t know if there is any plan for this. How do you route requests among multiple valkey instances? Is there any spec available?

@srikar-jilugu
Copy link
Contributor Author

Hi @rueian, we want the client to not get binded to a single cache endpoint(like it currently does), we ideally want it to have independent pooling for each cache,(similar to how the aws dynamodb sdk operates). This would allow users to specify the target cache dynamically at the command level.

For eg

ctx.Set(cacheName, "tenant1")
client.Get(ctx, "key")

or

cacheName = "tenant1"
client.Get(ctx, cacheName, "key")

@rueian
Copy link
Collaborator

rueian commented Mar 17, 2025

It seems like you are referring to a custom routing method instead of a widely accepted spec. I think the best option for you is still using multiple clients. Note that it is no difference between multiple clients and independent pooling for each cache.

@srikar-jilugu
Copy link
Contributor Author

Note that it is no difference between multiple clients and independent pooling for each cache.

Can singleClient be used to connect to elasticache serverless? Using multiple clusterClients would introduce additional overhead for cluster management operations, which isn’t necessary for a serverless setup. However, I’m unsure about this since AWS deploys serverless in cluster mode for some reason

@rueian
Copy link
Collaborator

rueian commented Mar 17, 2025

Try this option:

valkey-go/valkey.go

Lines 221 to 224 in aff64a7

// ForceSingleClient force the usage of a single client connection, without letting the lib guessing
// if valkey instance is a cluster or a single valkey instance.
ForceSingleClient bool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants