Open mrkurt opened 4 years ago
Thanks @mrkurt - this approach requires read/write splitting in the implementation code though, right?
ie - it's not what you'd called "active-active", and would require that your reads hit a different redis DSN to the writes, correct?
Kind of. You will have two addresses, like these:
REDIS_CACHE_URL
REDIS_GLOBAL_CACHE_URL
In this configuration, you'd mostly be reading AND writing against REDIS_CACHE_URL
. You'd only need to use the REDIS_GLOBAL_CACHE_URL
when you want data to propagate to all the regions.
This works because Redis allows writes against a replica.
Migrated to Discourse: https://community.fly.io/t/redis-cache-cluster/62
Redis makes a really nice global cache service. Replicas can be configured to allow writes with
replica-read-only false
. With a reasonably small dataset, replicas can be added and removed quickly too.Making this work on Fly (currently) requires two applications.
replica-read-only false
, and no disk persistence.The primary Redis is useful for propagating commands to all the replicas. A
del
sent to the primary will remove keys in all the replicas. Aset
will propagate to all the replicas. Writes to each replica are invisible to other replicas, so the best pattern for using this is to do most caching operations against the replica app, and only write to the primary app for things that need to be the same everywhere.