-
Notifications
You must be signed in to change notification settings - Fork 101
OSS Cluster Support
Users have requested Redis Cluster support for Redis OM Spring to enable use with clustered Redis deployments. Currently, the library only supports single Redis instances and Sentinel configurations.
Critical Limitation: RediSearch (the core search module used by Redis OM Spring) is fundamentally incompatible with Redis OSS Cluster mode.
-
Redis Official Documentation (Redis.io - OSS Cluster API):
"OSS clustering policy can't be used with the RediSearch module"
-
GitHub Issue #4588 (RediSearch Repository, April 2024):
"Please Help Fix RSCoordinator So that Redis Search (RediSearch) Can Be Used Across Redis Cluster - module-oss.so initialization failed"
- Multiple users report inability to use RediSearch with OSS Cluster
- Source: RediSearch/RediSearch#4588
-
Redis Community Forum (2023-2024):
"How can I handle redis-cluster with Redis Stack (RediSearch)?"
- Official response confirms RediSearch cannot work with standard Redis Cluster
- Users report: "cannot import data across nodes and can only access data within the same node"
- Source: Redis Community Forum Discussion
-
Azure Managed Redis Documentation (Microsoft, 2024):
"OSS clustering policy can't be used with the RediSearch module. The Enterprise clustering policy is the only one that can be used with the RediSearch module."
- Source: Azure Managed Redis Architecture
-
Stack Overflow Discussions (2024):
- Multiple threads confirm RediSearch doesn't work in cluster mode
- Users attempting to optimize RediSearch with Redis-Cluster report failures
- Source: Stack Overflow - Redisearch not work in a cluster
- RediSearch operations often require cross-slot operations that conflict with how Redis OSS Cluster distributes data across shards
- Search indexes need to span multiple keys which may be distributed across different cluster nodes
- Aggregation and full-text search queries cannot be efficiently executed across cluster boundaries
- This is an architectural limitation, not a simple configuration issue
Spring Data Redis provides robust cluster support through:
-
RedisClusterConnection
for cluster-aware connections -
ClusterOperations
interface viaRedisTemplate.opsForCluster()
- Automatic routing of commands to correct nodes
- Support for cross-slot operations (with performance penalties)
Key features:
- Automatic sharding across 16,384 slots
- Commands routed to appropriate nodes automatically
- Multi-key operations supported (but less performant when keys map to different slots)
The codebase shows minimal cluster preparation:
-
RedisModulesClient
has agetJedisCluster()
method that returns empty Optional (not implemented) -
IdAsHashTag
utility exists for hash tag support (useful for ensuring related keys map to same slot) -
getUnifiedJedis()
only handles Standalone and Sentinel modes, not Cluster
- Uses proxy-based architecture that makes cluster appear as single instance
- Supports RediSearch through RSCoordinator
- All requests route through proxy that internally handles distribution
- This is the only proven way to use RediSearch with clustering
- Distributed coordinator for RediSearch in clustered environments
- Available in Redis Enterprise (full version)
- Open source gets "RSCoordinatorLight" with limited functionality
- Has not been actively maintained (last meaningful updates 9+ months ago as of 2024)
References:
- RSCoordinator GitHub Repository: "RSCoordinator runs alongside RediSearch and distributes search commands across the cluster"
- Stack Overflow Discussion (2024): "The redis-stack-server images do NOT include the latest RSCoordinator"
- Community reports indicate RSCoordinator hasn't been updated recently and may have been rolled into RediSearch itself
- Manually partition data across multiple Redis instances
- Each instance runs RediSearch independently
- Application handles routing logic
- Complex but possible for specific use cases
- Supports cluster mode via
JedisCluster
- Can execute module commands on cluster
- Limitations: No transactions or pipelines in cluster mode
- Advanced cluster support with reactive/async capabilities
- Dedicated "lettusearch" library for RediSearch
- Better suited for reactive applications
Provide cluster support for basic Redis operations while clearly documenting RediSearch limitations:
public class RedisModulesClient {
private UnifiedJedis getUnifiedJedis() {
var clusterConfiguration = jedisConnectionFactory.getClusterConfiguration();
if (clusterConfiguration != null) {
// Cluster mode - with limitations
logger.warn("Cluster mode detected. RediSearch operations will be limited to single-slot operations.");
var nodes = clusterConfiguration.getClusterNodes().stream()
.map(node -> new HostAndPort(node.getHost(), node.getPort()))
.collect(Collectors.toSet());
return new JedisCluster(nodes, jedisClientConfig);
}
// ... existing sentinel and standalone logic
}
}
Pros:
- Enables basic Redis operations in cluster mode
- Users can use JSON storage with limitations
- Clear migration path when better solutions become available
Cons:
- RediSearch features severely limited
- Many operations will fail with cross-slot errors
- Poor user experience for search operations
Implement or recommend a proxy layer that makes cluster appear as single instance:
- Use Redis Enterprise (commercial solution)
- Implement custom proxy using redis-cluster-proxy
- Use third-party proxies like Twemproxy (with limitations)
Pros:
- Full RediSearch functionality maintained
- Transparent to application code
Cons:
- Additional infrastructure complexity
- Potential performance overhead
- May require commercial Redis Enterprise license
Implement sharding logic within Redis OM Spring:
public interface ShardingStrategy {
String selectShard(String key);
List<String> getAllShards();
}
public class ShardedRedisDocumentRepository {
private Map<String, RedisModulesClient> shardClients;
private ShardingStrategy shardingStrategy;
public void save(T entity) {
String shard = shardingStrategy.selectShard(entity.getId());
shardClients.get(shard).save(entity);
}
// Aggregate search results across shards
public List<T> search(Query query) {
return shardClients.values().parallelStream()
.flatMap(client -> client.search(query).stream())
.collect(Collectors.toList());
}
}
Pros:
- Full control over sharding logic
- Can optimize for specific use cases
- No external dependencies
Cons:
- Complex implementation
- Maintenance burden
- Performance implications for cross-shard queries
-
Document current limitations clearly
- Add warning in README about cluster incompatibility
- Provide guidance on alternatives (Sentinel, Redis Enterprise)
-
Implement basic cluster detection
- Detect cluster configuration
- Throw informative exception with alternatives
-
Add hash tag support for keys
- Extend
IdAsHashTag
functionality - Document how to use for related entities
- Extend
-
Investigate RSCoordinator integration
- Test with open source RSCoordinatorLight
- Document limitations vs Enterprise version
-
Implement limited cluster support
- Support JSON operations that don't require search
- Provide clear errors for unsupported operations
-
Create migration guide
- From single instance to Sentinel
- From OSS to Redis Enterprise
-
Consider alternative search solutions
- Evaluate if RediSearch alternatives emerge with cluster support
- Monitor RSCoordinator development
-
Implement application-level sharding
- If demand justifies complexity
- As optional feature with clear documentation
Redis Cluster support for Redis OM Spring is severely limited by RediSearch's incompatibility with OSS clustering. The most viable short-term approach is to:
- Clearly document the limitation
- Recommend Redis Enterprise for users needing clustering
- Provide limited support for non-search operations
- Monitor the ecosystem for emerging solutions
Users requiring both clustering and search capabilities should consider:
- Redis Enterprise (recommended)
- Multiple Sentinel deployments with application-level routing
- Alternative search solutions that support clustering
- Redis OSS Cluster API Docs - Confirms RediSearch incompatibility with OSS Cluster
- Spring Data Redis - Cluster Support - Details on Spring's cluster implementation
- Azure Managed Redis Architecture - Enterprise clustering requirements for RediSearch
- Redis Cluster Specification - Technical details of Redis Cluster
- redis/redis-om-spring#48 - Original cluster support request
- RediSearch/RediSearch#4588 - RSCoordinator and cluster compatibility issues
- RediSearch/RSCoordinator - Distributed coordinator for RediSearch
- redis/jedis - RediSearch Docs - Jedis support for RediSearch
- RediSearch/lettusearch - Lettuce-based client for RediSearch
- Redis Community Forum - RediSearch Cluster - User experiences with cluster limitations
- Stack Overflow - RediSearch Cluster Issues - Technical discussions on incompatibility
- Stack Overflow - RSCoordinator Updates - Current state of RSCoordinator
This research was conducted in August 2025, reflecting the state of Redis ecosystem and available solutions as of that time.