Introducing Dragonfly Cloud! Learn More

Question: What are the limitations of a Redis cluster?

Answer

Redis Cluster provides a way to run a Redis installation where data is automatically sharded across multiple Redis nodes. Even though it has many benefits, it also comes with several limitations:

  1. Cross-slot commands: In Redis Cluster, you can't perform operations that involve multiple keys unless they are all part of the same hash slot. This means commands like MSET, MGET, and DEL with multiple keys could fail if the keys are in different slots.

    # Will cause error if 'key1' and 'key2' are located in different slots. redis_cluster.mget('key1', 'key2')
  2. Transactions: Redis Cluster does not support multi-key transactions using commands like MULTI, EXEC, DISCARD and WATCH. However, single key operations are atomic as in single instance Redis.

  3. Lua scripts: Lua scripts have to be designed carefully. All keys that the script uses should be hashed to the same slot, meaning that they should all correspond to the same node.

  4. Database selection: The SELECT command is not available in cluster mode. Redis Cluster uses database 0 and cannot switch databases.

  5. Subset of commands are allowed in readonly mode: Read-only commands can be issued in read-only mode on slave nodes, but not all read-only commands are available.

  6. Node failures: While Redis Cluster is resilient to a point, simultaneous failure of a primary and its corresponding replica(s) would result in data loss for that shard.

  7. Adding or removing nodes: Redis Cluster does not support online resharding of data (moving data from one node to another) and rebalancing when nodes are added or removed.

Each of these limitations can be worked around or mitigated to some extent depending on your use case, but they do represent areas where behavior differs from standalone Redis installations. It's important to design your application keeping these limitations in mind when using Redis Cluster.

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

Start building today 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.