Redis Setup for PRODUCTION


I have a minimun setup for Sentinel with 1 master (R1), 1 slave (R2) and 3 sentinels.(S1,S2,S3)

       | R1 |
       | S1 |
+----+    |    +----+
| R2 |----+----|    |
| S2 |         | S3 |
+----+         +----+

If the master R1 fails, S2 and S3 will agree about the failure and will be able to authorize a failover, making clients able to continue and promote R2 as new master.

While R1 is down, writes are sent to R2 but any read (using client created with GetReadOnlyClient) fails with an InvalidOperationException that says “Need a minimum read pool size of 1, then call Start()”

Is there an easy way to promote the GetReadOnlyClient() to master server until there is no slave available?

And, which is the recommended setup for redis sentinel on production environments? It is not enougth 1 master and 1 slave?

i use RedisSentinel

string[] redisSentinelHosts = ...
string masterName = ...
var sentinel = new RedisSentinel(redisSentinelHosts, masterName);
sentinel.HostFilter = (host) => $"{host}?db={database}";
container.Register<IRedisClientsManager>(c => sentinel.Start());

The recommended setup is 1x Master, 2x Slaves and 3x Sentinels as documented in:

You don’t want to manually promote any slaves to master, that’s the role of the sentinels to detect the master is down and to promote one of the slaves.

Thank you, I will setup 1 master with 2 slaves instead of only 1

I was referring to whether get a read client (with GetReadOnlyClient()) how could get a client to a master when there is no slave available

You shouldn’t be using Redis when there’s no slaves available, there should be 2 slaves so when one goes down you can bring up another slave.

If GetReadOnlyClient() throws an Exception you can fallback to GetClient() which will return a connection to the master.

We took the apgroach to set 2 slaves and if the GetReadOnlyClient() fails abort until get 1 master + 1 slave online to ensure the service is not connected to a minority redis service