Reputation: 7454
I am evaluating redis as an caching alternative. The cache needs to deployed in a two data center clustered configuration with n machines in each of the data centers. From the available documentation I have been able to setup with relative ease a master/slave configuration. The application is a Rails app and currently only plan to use it for a cache store and will not be performing the more advanced set operations so data from the same set being in different physical boxes is not an issue. A few questions and clarification I had:
In the master/slave configurations what happens if the master node goes down? How is a new master node selected or elected? Does it need config change or can a new master selected on the running cluster? How do the applications using the store know which the new master is seamlessly? Is there any gem available which abstracts this logic from the end application?
Its generally not a good idea to have dependencies across data centers as one should plan for one data center going down and the application still scaling. However that does mean that each data item is cached twice one on each side. Though I thing the first point is more important than duplicate data. Is sharding the data across the two clusters the best of both worlds? What sharding support does redis provide? In the across data center configuration is it possible to have two master writers? And specifying that the app servers first try the slave nodes on the same side and only go to the other side if all the slaves on the same data center are down.
I am clear on howto configure the master/slave config as far as the redis servers go. How does one configure the clients to specify which is the master node and which are the slave read nodes? How is load distributed across the read nodes? Is there a way to configure a round robin scheme or each application server is configured to go to one slave for all reads?
Sorry for the large number of questions but any help would be greatly appreciated.
Upvotes: 3
Views: 5631
Reputation: 16174
The necessary commands are there, but you need to implement the node management on the client. The basic idea is to send "SLAVEOF NONE" to an available node when you detect that the master node is unreachable, but you can make this as complicated as you need to. I use a seperate redis instance that stores details of all nodes and is read if a client is unable to connect to the node it was using previously.
If redis is a cache rather than your primary data store, a cache for each datacenter is probably better - a cache hit in a different datacenter is likely just as expensive as a local cache miss. The only cross datacenter caching code you would need in this scenario is a way to invalidate the remote cache on write.
This depends on your client implementation - you can set up your application code to manage nodes however you need to.
Upvotes: 2