Skip to content
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

Support Redis in cluster mode #21

Merged
merged 3 commits into from
May 3, 2023
Merged

Conversation

bryce-fitzsimons
Copy link
Member

Supports Redis in cluster mode via 2 new environment variables:

  • USE_CLUSTER - "true" or "1" to enable
  • CLUSTER_ROOT_NODES - comma-separated URLs to your cluster seed nodes

@@ -170,43 +183,58 @@ export class RedisCache {

// Redis requires that subscribers use a separate client
this.subscriberClient = this.client.duplicate();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems that it is only necessary for the Redis client, not the Redis cluster.

https://github.com/redis/node-redis/blob/master/docs/pub-sub.md
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've switched the GB Proxy over to ioredis since node-redis has some issues with flakiness and incomplete TS bindings (specifically for cluster mode). Ioredis recommends using a separate client for subscribing even in cluster mode. While the general Redis docs indicate that you don't technically need to separate your subscribe client from normal usage due to how the Cluster message bus works, it's still a recommended practice to separate them (scalability, separation of concerns, flexibility) and there's no real downside to doing so.

Of course this is just my own research and I have not battle-tested this at scale. If you have scalability insights here, would be great to learn of them.

@bryce-fitzsimons bryce-fitzsimons merged commit 4cd5b58 into main May 3, 2023
@bryce-fitzsimons bryce-fitzsimons deleted the support-redis-cluster branch May 3, 2023 18:13
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

Successfully merging this pull request may close these issues.

3 participants