Redis Cluster Broker#
Overview#
FastStream provides a RedisClusterBroker for working with Redis Cluster. It is a drop-in replacement for RedisBroker with the same constructor API, designed for multi-node cluster deployments.
When to Use#
| Use RedisBroker | Use RedisClusterBroker |
|---|---|
| Single Redis instance | Multi-node cluster |
| Development / testing | Production with HA |
Need pipeline support | Can tolerate no pipeline |
Connecting#
A single URL is enough — the cluster auto-discovers the remaining nodes:
For multi-address environments you can explicitly specify seed nodes via startup_nodes:
Feature Support#
| Feature | RedisBroker | RedisClusterBroker |
|---|---|---|
| List | ✅ | ✅ |
| Stream + XAUTOCLAIM | ✅ | ✅ |
| Pub/Sub | ✅ | ✅ (via sync cluster) |
| Pipeline | ✅ | ❌ |
Stream Location#
In Redis Cluster every key (including stream names) is assigned to one of 16384 hash slots, each served by a specific node. Consumer groups and XREADGROUP operate within that single node. This is transparent to the client — RedisCluster handles routing automatically.
Cross-node reads
A stream with a consumer group can only be read from the node that owns its hash slot. The cluster client handles this routing; no manual configuration is needed.
Migration from RedisBroker#
RedisClusterBroker accepts the same parameters as RedisBroker, so migration is a one-line change:
# Before
from faststream.redis import RedisBroker
broker = RedisBroker(url="redis://localhost:6379")
# After
from faststream.redis import RedisClusterBroker
broker = RedisClusterBroker(url="redis://localhost:7000")
Limitations#
- Pipeline is not supported in Redis Cluster.
- XAUTOCLAIM with
min_idle_timerequires a consumer group withgroupandconsumerparameters onStreamSub. - Pub/Sub uses a synchronous
RedisClusterclient (viaThreadPoolExecutor) because the async client does not exposepublish/pubsubuntilredis-py >= 8.0.0.