Easy Tutorial
❮ Strings Msetnx Connection Select ❯

Redis Partitioning

Partitioning is the process of dividing data across multiple Redis instances, so that each instance stores only a subset of the keys.

Advantages of Partitioning

Disadvantages of Partitioning

Some Redis features do not perform well with partitioning:


Types of Partitioning

Redis supports two types of partitioning. Assuming there are four Redis instances R0, R1, R2, R3, and multiple keys representing users like user:1, user:2, there are different ways to decide which instance a key should be stored in. That is, there are different systems to map a key to a specific Redis server.

Range Partitioning

The simplest form of partitioning is range partitioning, which maps a range of objects to a specific Redis instance.

For example, users with IDs from 0 to 10000 are stored in instance R0, users with IDs from 10001 to 20000 are stored in instance R1, and so on.

This method is feasible and used in practice, but it requires a mapping table from range to instance. This table needs to be managed, and a mapping table for various objects is typically not a good approach for Redis.

Hash Partitioning

Another partitioning method is hash partitioning. This works for any key and does not require it to be in the format of object_name:

❮ Strings Msetnx Connection Select ❯