Skip to content

Redis Cluster support for Mojo::Redis #26

@Yenya

Description

@Yenya

Mojo::Redis is a Redis database plug-in for the excellent Mojolicious real-time web framework. It works for a single Redis database, and probably, through underlying libraries, also for Redis Sentinel setups using master/replica instances.

Redis Cluster is much more capable than Sentinel: it shards the Redis keyspace to several instances, each of which can have replica(s), and requires the client to maintain a notion of which keys belong to which instance, and connect to/query the appropriate instance itself. It also provides the -MOVED/-ASKING error state for notifying connected clients that the cluster configuration has changed, and the requested key is now elsewhere. The cluster nodes themselves speak the Redis protocol plus some extensions, but handle only part of the keyspace.

There are two implementations of Redis Cluster protocol: pure Perl Redis::Cluster, which seems to be unmaintained, and needs patching for current Redis protocol, and Redis::Cluster::Fast, which is based on hiredis-cluster C library. The former uses an interesting approach where read-only requests can be optionally directed to replicas instead of the master node of a given shard.

To use Redis Cluster protocol in Mojolicious, an event-driven and Promise-based module similar to Mojo::Redis needs to be written. Something that maintains the cluster state and maybe uses the Mojo::Redis objects to connect to each individual cluster node, and which directs the requests to particular shards and responds to the -MOVED error messages appropriately.

There was an enhancement request for Mojo::Redis, but the maintainer responded that he doesn't have time to write the Cluster support himself, but is willing to look at the merge request.

Thanks for considering this!

-Yenya

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions