0

I forgive me for my shallow knowledge, but I have not to figure out why I need 3 servers to manage fail-over with Redis?

I have a application served under load-balancer with to server instances, and I am looking to setup Redis for session & notification management.

My requirement is simple that I want to install Redis on both servers and have a fail-over plan if one server fails so the the end-user do not gets affected in terms of session & notifications.

What are my options ? Thanks in advance.

Aditya T
  • 1,566
  • 2
  • 13
  • 26

2 Answers2

0

If you only have two servers, then there is atleast one problem which i can think of. What if there was a network issue between your master and the slave. If it leads to slave becoming the master, then you will have two masters(because the first one never went down, remember). This is known as a Split Brain Scenario.

To avoid split brain scenario, one should have odd no of masters, and define quorum appropriately in the redis-sentinel.conf file(ideally it should be (n+1)/2), ie a simple majority.

It means that if you have 3 nodes, 1 master+2 slaves with quorum of 2. And if there is a network error, somehow two instances which are in touch with each other will be master(quorum of 2).

So, the idea is just to have odd no of instances, and have appropriate quorum set.

Spock
  • 184
  • 3
  • Thanks for your input, not sure how can I take this as a answer. Regarding the Split Brain Scenario you mentioned, I can not put more than 2 server instances ( client requirement ). So I am looking for a solution where I just have 2 servers and can have a fail-over plan. Also, the scenario you mentioned looks rare to me as both servers would be in same region, so even if this is likely, how can i setup the environment for failover. – Aditya T Apr 03 '18 at 09:15
  • what you can do is the following. Have 2 servers. Run redis on port 6379 on server1, sentinel on 26379 on server1. Same on server 2. Now, have a third server, which can be a shared one. just run sentinel on it(it won't use too many resources). and have quorum as 2. So, that means use 3 sentinels, 2 redis. – Spock Apr 03 '18 at 09:16
  • 'looks rare', but is definitely possible. you must not have heard of racks, or datacenters going down. Even in the above case, your 3 redis sentinels/nodes should be on different 'physical' machines, not on different virtual machines. – Spock Apr 03 '18 at 09:20
  • If your clients are interested in high availability, show them the first two points from here. https://redis.io/topics/sentinel#fundamental-things-to-know-about-sentinel-before-deploying – Spock Apr 03 '18 at 09:22
  • Well, no of the above works for me. I need a setup with just 2 servers, no extra server for any reason. – Aditya T Apr 05 '18 at 09:57
  • hey @Spock how can I run sentinel only? It should be associated with the redis-server running in its host server rit?? I can run 3redis 3sentinel but can't 3redis 4sentinel.....Please let me know how to set up sentinel only. – AATHITH RAJENDRAN May 27 '19 at 04:18
0

I ended up using Hazelcast for my scenario as it is able to fail-over if only one instance fails at a time. So simple answer is to use HAZELCAST if you have a restriction of 2 servers only.

Aditya T
  • 1,566
  • 2
  • 13
  • 26