Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Redis Partitioning

Redis Partitioning

Partitioning is the process of splitting data across multiple Redis instances, so each instance only holds a subset of the keys.

Advantages of Partitioning

Disadvantages of Partitioning

Some of Redis's features do not perform well with partitioning:


Partition Types

There are two types of partitioning in Redis. Suppose there are 4 Redis instances R0, R1, R2, R3, and multiple keys representing users such as user:1, user:2. For a given key, there are various ways to choose which instance it is stored in. That is, different systems map a key to a particular Redis service.

Range Partitioning

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

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

This approach is feasible and used in practice, but its drawback is that it requires a mapping table from ranges to instances. This table must be managed, along with mapping tables for various objects, which is usually not a good approach for Redis.

Hash Partitioning

Another partitioning method is hash partitioning. It applies to any key and does not need to be in the object_name:form, and is as simple as described below: