Writable replicas: yes or no? #9760
Replies: 5 comments 11 replies
-
Writable replicas create some seemingly-useful caching possibilities, like pushing shared cache state to replicas through replication while allowing the replicas to develop location-specific caches through writes. Fly describes this pattern: https://fly.io/blog/last-mile-redis/ I'm not sure how widely used this approach is, but it's cool! |
Beta Was this translation helpful? Give feedback.
-
Please don't remove replica writes. Or, if possible, create a way to have loosely coupled replicas.
We use them for globally coordinated caches (see above URL).
Yes, we write to the leader to propagate changes everywhere, purge keys, etc. Writes to replicas will overwrite those changes. We even do things like
No, not necessarily. Replicas can have long lived, replica only data. We sometimes set TTLs on the leader and then reset them on the replicas. It's a handy way to push a possible change to all the replicas and then let them vanish if they don't get used. |
Beta Was this translation helpful? Give feedback.
-
Hi – I use writes on replicas! The big case that I don't see addressed here yet is when consistency is not important but availability and cache performance is. Consider a distributed application that needs to migrate from one Redis instance to another. Redis is used as a flat cache where write order isn't important and a (Redis) cache miss incurs a performance penalty but no errors: With replica writes enabled, we can update the application configuration(s) to point to the new Redis instance without any additional coordination. Cache hit ratio stays high during the transition because a meaningful percentage of writes from the old Redis flow through to the new Redis where both reads and writes are happening. Eventually the application stops writing to the old Redis altogether, the new Redis is promoted, and business continues as normal before the migration event occurred. If replica writes did not exist, I think we would either have to take (1) an availability hit to coordinate the application to switch the destination of all writes at once, or (2) a drop in cache hit ratio by disconnecting replication before pointing any writes at the new Redis. So to answer @itamarhaber's questions:
|
Beta Was this translation helpful? Give feedback.
-
Hi @bpo thanks for your report. The case you said is very common, many users in our platform migrate data from one instance to another everyday, but we use more elegant way to solve:
So I don't think redis needs handle this case internally, using a middle ware is more reasonable and flexible. BTW, redis is not only cache. |
Beta Was this translation helpful? Give feedback.
-
Is writable replica still supported? On performing any 'STORE' operation like 'ZRANGESTORE' or 'ZUNIONSTORE' on a replica node of a Redis Cluster, I a getting MOVED exception even when 'replica-read-only' is set to 'no'. Is there any other configuration required to make a replica writable? My use case for Writable replica - Redis version - |
Beta Was this translation helpful? Give feedback.
-
TL;DR Since time immemorial, Redis has allowed stand-alone and cluster replicas to be configured so they can accept write requests. If you have an opinion about this feature, please add your voice to this discussion.
The primary use of Redis replicas is to provide a highly-available database service via failover and promotion. Replicas can also be used to offload reads from the master. However, a client can write to a replica under certain conditions (with the proper configuration and/or connection settings).
The motivations for making replicas writable, as far as we're aware, were mainly to support these use cases:
a. Allow creating (and possibly deleting) temporary keys, such as those that
ZUNIONSTORE
producesb. Allow using commands that have the potential to write to keys, even if they don't necessarily do so, such as with using
SORT
in its read-only invocation form.However, with Redis v6.2 and the upcoming v7, a slew of new
_RO
commands and complementary non-STORE
variants have been added to address just that.If that's indeed the case, namely that writable replicas are no longer really needed, the next question is whether they are needed at all. Supporting write replicas not only adds to the overall complexity of the project but also introduces several edge cases that, while rare, have damage potential during runtime. While the effort can be invested to address some/all of the issues, we're looking to assess the need and requirements from the feature.
So the questions we are looking to answer are mainly:
Thanks in advance for your participation!
Beta Was this translation helpful? Give feedback.
All reactions