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:
-
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
, andDEL
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')
-
Transactions: Redis Cluster does not support multi-key transactions using commands like
MULTI
,EXEC
,DISCARD
andWATCH
. However, single key operations are atomic as in single instance Redis. -
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.
-
Database selection: The
SELECT
command is not available in cluster mode. Redis Cluster uses database 0 and cannot switch databases. -
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.
-
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.
-
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?
Other Common Redis Questions (and Answers)
- What is the default port used by Redis?
- How to start Redis server?
- Is Redis persistent?
- How fast is Redis?
- How to install Redis on Mac?
- How to check if Redis is running?
- How to restart Redis?
- Does Redis persist data?
- How to install Redis on Ubuntu?
- How to stop Redis server?
- How to see Redis version?
- Does Redis have tables?
Free System Design on AWS E-Book
Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.
Switch & save up to 80%
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost