Question: What is redis replication priority and how is it used?

Answer

In Redis, replication priority is a configurable parameter used by the Sentinel system to decide which replica will be promoted to master when the current master fails. This priority is defined with the slave-priority configuration directive in the Redis configuration file.

The lower the number, the higher the priority. A slave with a priority of zero can never be promoted to master.

Here is an example of setting the replication priority in the Redis configuration file:

slave-priority 100

It's important to mention that if several replicas have the same priority, the one with the smallest replication offset (i.e., the most up-to-date) is selected.

Replication priority can be useful in scenarios where certain replicas are known to have more resources or are more reliable than others, thus should be preferred for promotion to the master role. By tweaking this value on each Redis instance, you can influence the behavior of your distributed Redis system during failovers.

Was this content helpful?

Start building today

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.