Using SignalR with Redis messagebus failover using BookSleeve's ConnectionUtils.Connect()

后端 未结 1 929
自闭症患者
自闭症患者 2021-01-31 06:56

I am trying to create a Redis message bus failover scenario with a SignalR app.

At first, we tried a simple hardware load-balancer failover, that simply monitored two Re

相关标签:
1条回答
  • 2021-01-31 07:30

    The SignalR team has now implemented support for a custom connection factory with StackExchange.Redis, the successor to BookSleeve, which supports redundant Redis connections via ConnectionMultiplexer.

    The initial problem encountered was that in spite of creating my own extension methods in BookSleeve to accept a collection of servers, fail-over was not possible.

    Now, with the evolution of BookSleeve to StackExchange.Redis, we can now configure collection of servers/ports right in the Connect initialization.

    The new implementation is much simpler than the road I was going down, in creating a UseRedisCluster method, and the back-end pluming now supports true fail-over:

    var conn = ConnectionMultiplexer.Connect("redisServer1:6380,redisServer2:6380,redisServer3:6380,allowAdmin=true");
    

    StackExchange.Redis also allows for additional manual configuration as outlined in the Automatic and Manual Configuration section of the documentation:

    ConfigurationOptions config = new ConfigurationOptions
    {
        EndPoints =
        {
            { "redis0", 6379 },
            { "redis1", 6380 }
        },
        CommandMap = CommandMap.Create(new HashSet<string>
        { // EXCLUDE a few commands
            "INFO", "CONFIG", "CLUSTER",
            "PING", "ECHO", "CLIENT"
        }, available: false),
        KeepAlive = 180,
        DefaultVersion = new Version(2, 8, 8),
        Password = "changeme"
    };
    

    In essence, the ability to initialize our SignalR scale-out environment with a collection of servers now solves the initial problem.

    0 讨论(0)
提交回复
热议问题