Using Redis Replication on different machines (multi master)

I want to use Redis as a distributed cache in my application. One of the requirements is Active Active, which means I have one datacenter in one location and another one somewhere else. If one datacenter fails, I want my user to feel nothing and be able to have all the data from the first datacenter on the second site and keep going - have a master on the second site. Is it possible?

+1


source to share


1 answer


You are asking for an Active-Active solution, aka, but your question suggests that you might not need it.

If only one of the databases is required for recording, i.e. all records always go, you can achieve this with standard Master-Slave Redis replication. Direct the application to use a wizard for writing and (potentially) having your subordinate serve some of the read. If the master fails, promote the slave to the Secondary DC to become the new master and redirect the application / clients to use it. Monitoring and promotion can be achieved with Sentinel Redis.

There are a few things you will need to consider when implementing this type of customization. First of all, note that Redis redundancy is asynchronous, so depending on your base load, write volume, and replication link quality, you might lose some of the latest updates in the event of a failure. Second, on the same topic, network communication between DCs can be subject to limited bandwidth and increased latency - you must configure Redis to handle this, and possibly use compression for that traffic (e.g. via an SSH tunnel). Finally, for accurate crash detection, you'll want to have at least 3 Sentinels in different locations. But despite these challenges, it’s all doable.



However, a multi-page setup in which writes can be performed arbitrarily against any database not currently supported by Redis. If this is really what you want, consider using a different solution.

Note: depending on your exact requirements, if you can guarantee that the entries in different domain controllers are mutually exclusive (i.e. each DC only gets entries for a particular subset of keys that are not used by another DC), you can use two databases with a master in each DC and a slave in another.

+5


source







All Articles