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.
- A “primary” Redis app with a min-count and max count of 1, it should not scale.
- A replica Redis app configured to replicate from the primary Redis,
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. A set
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.
(Moved from here: https://github.com/superfly/fly/issues/294)