Search code examples
redisservicestack.redisservicestack-bsd

ServiceStack.Redis v3 and multiple hosts - recommended architecture


We are experiencing an issue where multiple instances of RedisMqServer are tripping up over each other - stopping one server stops the others. Clearly the way we have implemented this is wrong, but I can't identify how one is supposed to use RedisMqServer in this situation.

Our infrastructure consists of:

  • Two Redis servers in a master/slave configuration
  • Two load-balanced API instances (referred to as 'API A' below)
  • Two load-balanced API instances (referred to as 'API B' below)

API A and B are two independent applications which use ServiceStack.Redis's RedisMqServer to send both synchronous and asynchronous messages to each other. We are using the open source v3 revision of ServiceStack.

Both APIs have a RedisMqServer configured, as asynchronous communication happens in both directions.

When RedisMqServer is disposed, it sends a STOP message on the mq:topic:in channel, which results in the server unsubscribing from all channels and therefore stopping it from servicing requests.

However because this channel is being used by both API A and API B, stopping either one ends up stopping the other.

Is one supposed to use a single Redis server instance per instance of RedisMqServer?

Of note, each API is only connecting to a single Redis server at any point in time. The slave server is only connected to if the master becomes unavailable.


Solution

  • This is the behavior with Redis MQ in v3, but the latest RedisMqServer in v4 works as expected and only stops the RedisMqServer instance that was disposed.