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

Redis Sentinel support #5141

Closed
kontrollanten opened this issue Jul 23, 2022 · 3 comments · Fixed by #5593
Closed

Redis Sentinel support #5141

kontrollanten opened this issue Jul 23, 2022 · 3 comments · Fixed by #5593

Comments

@kontrollanten
Copy link
Contributor

Describe the problem to be solved

Currently the only way to ensure high availability for the redis server is to use master/slave setup with manual handling when making system upgrades.

Describe the solution you would like

Redis Sentinel provides high availability for Redis when not using Redis Cluster.

  • Monitoring. Sentinel constantly checks if your master and replica instances are working as expected.
  • Notification. Sentinel can notify the system administrator, or other computer programs, via an API, that something is wrong with one of the monitored Redis instances.
  • Automatic failover. If a master is not working as expected, Sentinel can start a failover process where a replica is promoted to master, the other additional replicas are reconfigured to use the new master, and the applications using the Redis server are informed about the new address to use when connecting.
  • Configuration provider. Sentinel acts as a source of authority for clients service discovery: clients connect to Sentinels in order to ask for the address of the current Redis master responsible for a given service. If a failover occurs, Sentinels will report the new address.

Read more at https://redis.io/docs/manual/sentinel/

The currently used redis client doesn't support sentinels though, so a switch to ioredis would be needed. https://github.com/luin/ioredis#sentinel

@kontrollanten
Copy link
Contributor Author

Since implementing bullmq (which is using ioredis) this should be easy to add support for.

BullMQ uses the node module ioredis, and the options you pass to BullMQ are just passed to the constructor of ioredis.

https://docs.bullmq.io/guide/connections

ioredis supports Sentinel out of the box. It works transparently as all features that work when you connect to a single node also work when you connect to a sentinel group. Make sure to run Redis >= 2.8.12 if you want to use this feature. Sentinels have a default port of 26379.
To connect using Sentinel, use:

const redis = new Redis({
 sentinels: [
   { host: "localhost", port: 26379 },
   { host: "localhost", port: 26380 },
 ],
 name: "mymaster",
});

redis.set("foo", "bar");

https://github.com/luin/ioredis#sentinel

@kontrollanten
Copy link
Contributor Author

To be able to implement sentinel support we have to switch from node-redis to ioredis, since node-redis doesn't have sentinel support redis/node-redis#302

kontrollanten added a commit to kontrollanten/PeerTube that referenced this issue Feb 10, 2023
kontrollanten added a commit to kontrollanten/PeerTube that referenced this issue Apr 5, 2023
kontrollanten added a commit to kontrollanten/PeerTube that referenced this issue Apr 5, 2023
@ROBERT-MCDOWELL
Copy link
Contributor

is anyone know this very popular fork? https://github.com/Snapchat/KeyDB
looks much better than redis since it allows multimaster!

Chocobozzz pushed a commit to kontrollanten/PeerTube that referenced this issue May 10, 2023
Chocobozzz added a commit that referenced this issue May 10, 2023
* feat(server): add redis sentinel support

closes #5141

* Styling

---------

Co-authored-by: Chocobozzz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants