Dragonfly Cloud is now available on the AWS Marketplace - Learn More

Question: What does the "redis replica-read-only" configuration do and how can you use it?

Answer

The "redis replica-read-only" is a configuration option in Redis that controls whether clients connected to replica instances are allowed to execute write operations.

When replica-read-only is set to yes, which is its default setting, the replica server will reject all write commands from clients. This ensures that all write operations go through the primary (master) server, promoting consistency across your Redis architecture.

If you want to change this setting, you can do so in your Redis configuration file or on the fly using the CONFIG SET command if your system requires different behavior. Here's how you can change it:

redis-cli CONFIG SET replica-read-only no

This command allows write operations to be executed on the replica. However, keep in mind that these changes will not be propagated back to the primary server or other replicas. It also increases the risk of data inconsistency due to concurrent writes on the primary and replica servers. Therefore, it's generally best to leave this option enabled unless you have a specific use case that requires otherwise.

It's important to note that the changes made with CONFIG SET are not persistent. If you want to make a permanent change, you need to edit the Redis configuration file (redis.conf) directly:

replica-read-only no

And then restart your Redis server for the changes to take effect.

Was this content helpful?

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost