I'm looking at StackExchange.Redis and notice it has features for automatically determining which of the configured servers is master, and which are slaves.
I've not managed to spot what StackExchange actually does with the configured Masters/Slaves. Does it always run commands on Master, and only use configured Slaves for failover? Or is the answer more in-depth than that?
Any pointers appreciated!
The key thing here is
CommandFlags
, a parameter on every method. By default, most arePreferMaster
, however; note that write commands escalate toDemandMaster
automatically. However, if you want to spread load, you can elect to push some read commands (preferably the expensive ones) to slaves viaPreferSlave
andDemandSlave
.The other things it let's you do is to switch master (promote to master) - although this is naturally more invasive.