feat: Add multi-process worker support with Redis-based task storage#5
Merged
justrach merged 4 commits intoJan 20, 2026
Merged
Conversation
Owner
|
Hey! The CI is failing due to deprecated GitHub Actions versions in the workflow file. I've just pushed a fix to main that updates them to v4/v5. Could you rebase your branch on main to pick up the fix? Thanks! |
- Serialize task functions/args/kwargs to Redis using cloudpickle - Workers load payloads from Redis instead of in-memory storage - Enables distributed workers across multiple processes/machines - Add max_circuit_breaker_failures config to disable circuit breaker - Implement automatic cleanup of task payloads after completion Implements roadmap item: 'Distributed workers with coordination for multi-process scaling'
b725191 to
d00e32d
Compare
Owner
|
LGTM |
justrach
added a commit
that referenced
this pull request
Jan 28, 2026
- Add explicit connection pool size (max_connections=50) - Pipeline submit_task: 5 Redis calls → 2 pipelines (60% reduction) - Pipeline _process_queue: batch task_info + payload fetch - Optimize _execute_task: pass queue_name to avoid redundant GETs - Batch cleanup: use unlink for non-blocking batch deletes - Optimize get_ongoing_tasks: use MGET instead of N+1 GETs Benchmark results: - submit_task: 0.945ms → 0.295ms (69% faster, 3.2x speedup) - cleanup_500_keys: 890ms → 609ms (32% faster) - get_ongoing_tasks: 288ms → 193ms (33% faster) - throughput: 855 → 1506 tasks/sec (76% faster, 1.8x speedup) Also updates README with: - v0.1.7 feature highlights (multi-process support) - Credits to @Ahmad-cercli for PR #5 - Updated roadmap with completed/planned features - New Contributors section Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements multi-process worker support by storing task execution details in Redis instead of in-memory dictionaries.
Problem
Current implementation stores task payloads (
func,args,kwargs) in process-local memory (worker_pool._tasks), which breaks when running multiple worker processes:This makes Kew incompatible with common production patterns like Uvicorn/Gunicorn with
--workers N > 1.Solution
Store task payloads in Redis using
cloudpickleserialization, enabling any worker process to execute any task.Key Changes
1. Task Payload Storage (
submit_task)func/args/kwargswithcloudpickle.dumps()task_payload:{task_id}with base64 encoding (fordecode_responses=Truecompatibility)TASK_EXPIRY_SECONDS)2. Task Execution (
_process_queue)worker_pool._taskscloudpickle.loads()3. Circuit Breaker Configuration
max_circuit_breaker_failuresparameter toQueueConfig4. Cleanup Improvements
task_payload:*keys after task completionTASK_PAYLOAD_PREFIXconstant for consistencyBackward Compatibility
QueueConfigparameters compatible (new param has default)Testing
Tested in production with:
Dependencies
cloudpickle>=3.0.0for robust function/closure serializationChecklist
Related Issues
Implements roadmap item: "Distributed workers with coordination (locks) for multi-process scaling"