Skip to content

5. Data partitioning (sharding)

Nikita Koksharov edited this page Jan 19, 2023 · 50 revisions

This feature available only in Redisson PRO edition.

1. Partitioning (sharding) of Redis based Java objects

All Redisson Java objects are Redis cluster compatible, but their state isn't scaled/partitioned to multiple Redis master nodes in cluster. Redisson PRO offers data partitioning for some of them. This feature offers several advantages:

  1. State of single Redisson object evenly distributed across Redis master nodes instead of single master node. This allows to avoid Redis OutOfMemory problem.
  2. Scaling read/write operations to all Redis master nodes.

Redisson splits data to 231 partitions by default. Minimal number of partition is 3. Partitions are uniformly distributed across all Redis cluster nodes. This means that each node contains nearly equal amount of partitions. For default partitions amount (231) and 4 master nodes in Redis cluster, each node contains nearly 57 data partitions. 46 data partitions per node for 5 master nodes cluster and so on. This feature achieved thanks to special slot distribution algorithm used in Redisson.

Data partitioning supported for Set, Map, BitSet, Bloom filter, Spring Cache, Hibernate Cache, JCache and Micronaut Cache structures.

2. Partitioning (sharding) of Redis setup

Multiple Redis setups with limited amount of memory could be joined and used as a single partitioned (sharded) Redis environment.

RedissonClient redisson1 = ...;
RedissonClient redisson2 = ...;
RedissonClient redisson3 = ...;

RedissonClient redisson = ShardedRedisson.create(redisson1, redisson2, redisson3);