You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds Redis Cluster support to Docket via `redis+cluster://` and
`rediss+cluster://` URL schemes.
When using a cluster URL, all Redis keys are automatically hash-tagged
(e.g., `{my-docket}:queue`) to ensure multi-key Lua scripts and
operations land on the same slot. The cluster-awareness is fully
compartmentalized in `_redis.py`, so the rest of the codebase doesn't
need to know whether it's talking to a standalone Redis or a cluster.
Other changes that came along for the ride:
- `RedisConnection` now uses `urlparse` instead of string comparisons
for URL handling
- `ResultStorage` extracted to its own module with proper connection
pool lifecycle management
- `StrikeList` lifecycle simplified to standard async context manager
pattern
- Test infrastructure supports `REDIS_VERSION=8.0-cluster` for running
the full suite against a real cluster
Closes#120
🤖 Generated with [Claude Code](https://claude.ai/code)
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/production.md
+60-9Lines changed: 60 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Running Docket at scale requires understanding its Redis-based architecture, con
4
4
5
5
## Redis Streams Architecture
6
6
7
-
Docket uses Redis streams and sorted sets to provide reliable task delivery with at-least-once semantics. Note that Docket requires a single Redis instance and does not support Redis Cluster.
7
+
Docket uses Redis streams and sorted sets to provide reliable task delivery with at-least-once semantics.
8
8
9
9
### Task Lifecycle
10
10
@@ -167,10 +167,46 @@ async with Docket(name="orders", connection_pool=pool) as docket:
167
167
168
168
### Redis Requirements
169
169
170
-
Docket requires a single Redis instance and does not currently support Redis Cluster. For high availability, consider:
170
+
Docket supports both standalone Redis and Redis Cluster deployments. For high availability, consider:
171
171
172
172
-**Managed Redis services** like AWS ElastiCache, Google Cloud Memorystore, or Redis Cloud
173
-
-**Redis replicas** with manual failover procedures
173
+
-**Redis Cluster** for horizontal scaling and automatic failover
174
+
-**Redis replicas** with manual failover procedures for standalone deployments
175
+
176
+
### Redis Cluster Support
177
+
178
+
Docket supports Redis Cluster using the `redis+cluster://` URL scheme:
- Uses hash-tagged keys (`{docket_name}:*`) to ensure all keys hash to the same slot
206
+
- Manages cluster client lifecycle and connection distribution
207
+
- Handles pub/sub through a dedicated node connection (cluster pub/sub limitation)
208
+
209
+
**Note:** All Docket data for a single docket name will be stored on the same cluster shard. This ensures atomicity for Lua scripts and simplifies data management, but means individual dockets don't benefit from cluster data distribution.
When using Redis ACLs with a restricted user, grant access to the key pattern matching your docket name. All Docket keys follow the pattern `{docket_name}:*`:
225
+
When using Redis ACLs with a restricted user, grant access to the key pattern matching your docket name.
226
+
227
+
**Standalone Redis:** Keys follow the pattern `{docket_name}:*`
190
228
191
229
```bash
192
230
# Create a user with restricted permissions for a docket named "orders"
193
231
ACL SETUSER docket-user on >secure-password ~orders:*&orders:* +@all
194
232
```
195
233
234
+
**Redis Cluster:** Keys are hash-tagged with curly braces `{docket_name}:*`
235
+
236
+
```bash
237
+
# For cluster mode, the pattern includes the hash tag braces
238
+
ACL SETUSER docket-user on >secure-password ~{orders}:*&{orders}:* +@all
239
+
```
240
+
196
241
The required permissions are:
197
242
198
-
-**Key pattern**: `~{docket_name}:*` - matches all Redis keys used by Docket
199
-
-**Channel pattern**: `&{docket_name}:*` - required for task cancellation pub/sub
243
+
-**Key pattern**: `~{docket_name}:*`(standalone) or `~\{docket_name\}:*` (cluster) - matches all Redis keys used by Docket
244
+
-**Channel pattern**: `&{docket_name}:*`(standalone) or `&\{docket_name\}:*` (cluster) - required for task cancellation pub/sub
200
245
-**Commands**: `+@all` or the specific command categories Docket uses
201
246
202
247
For production deployments, you may restrict to only the required command categories:
203
248
204
249
```bash
205
-
# More restrictive command permissions
250
+
# More restrictive command permissions (standalone)
- Use managed Redis services for high availability (Redis Cluster is not supported)
632
+
- Use managed Redis services for high availability
633
+
- Deploy Redis Cluster for horizontal scaling with the `redis+cluster://` URL scheme
583
634
- Monitor memory usage and eviction policies
584
-
- Scale vertically for larger workloads
635
+
- Scale vertically for larger workloads on standalone Redis
585
636
586
637
Running Docket in production requires attention to these operational details, but the Redis-based architecture and monitoring support can help with demanding production workloads.
0 commit comments