Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StackExchange.Redis client with master/slave server - how to handle a failed master

Tags:

redis

I'm doing a proof-of-concept setup on Redis with master/slave and sentinel setup for high availability using StackExchange.Redis and am having some issues with using StackExchange.Redis.

I have successfully setup 3 Ubuntu VMs with the latest Redis server, one server is Master with Sentinel, one is Slave with Sentinel and the other is purely Sentinel. By using the CLI I can see that replication from master to slave is working correctly and when I stop the master (sudo services redis_6379 stop) the slave is promoted to master.

However, when trying to use the StackExchange.Redis

ConnectionMultiplexer redis;
ConfigurationOptions options = ConfigurationOptions.Parse("172.20.74.40:6379,172.20.74.41:6379");
options.AbortOnConnectFail = false;
redis = ConnectionMultiplexer.Connect(options);

I find that this works perfectly when both servers are up, but when the master is taken down Sentinel responds correctly, the slave is promoted to master, but the connection from the app to the cluster takes between 12 and 40 seconds to connect for every attempt (i.e. it never gets faster).

Am I missing something here? I'm trying to achieve high availability but this lag is clear not acceptable for this.

like image 792
user1120058 Avatar asked Feb 29 '16 11:02

user1120058


1 Answers

StackExchange.Redis does not support Sentinel. There's a big discussion about it on this Github issue.

In a nutshell: StackExchange doesn't use Sentinel. There was no use case for them to build support for it.

Here you can see Marc Gravell describing how it works with multiple endpoints.

like image 126
Bruno Garcia Avatar answered Nov 15 '22 12:11

Bruno Garcia