A simple distributed job queue built on Redis, supporting multiple concurrent producers and consumers with safe job processing and retry handling.
This project implements a lightweight background job queue using Redis as the coordination layer.
It supports:
- Multiple producers enqueueing jobs concurrently
- Multiple consumers processing jobs concurrently
- Blocking job consumption (no polling)
- Retry logic
- Optional dead-letter queue
- Producers push jobs into a Redis list
- Consumers block on the list and process jobs
- Redis guarantees atomic push/pop operations
Basic flow:
- Producer →
LPUSH queue - Consumer →
BRPOP queue - Process job
- Retry or move to DLQ on failure
| Key | Type | Purpose |
|---|---|---|
queue |
List | Pending jobs |
queue:processing |
List | In-flight jobs |
queue:dlq |
List | Failed jobs |
For safer processing, use:
BRPOPLPUSH queue queue:processing
This prevents job loss if a consumer crashes mid-processing.
After installing Redis, run executable from command line:
redis-server
Redis will be running in the foreground.
Run the job queue server:
python3 -m server.server
Run a single consumer:
python3 -m client.consumer
Run multiple consumers to test concurrency:
python3 -m client.consumer & python3 -m client.consumer &
Run a producer:
python3 -m client.producer
-
Consumer crash:
Use a processing queue to avoid losing jobs. -
Job failure:
Retry up to a max limit, then move toqueue:dlq. -
Redis restart:
Enable AOF persistence for durability.
Scale horizontally by:
- Running more producers
- Running more consumers
Redis handles synchronization.
Redis provides:
- Atomic list operations
- Blocking pop
- High performance
- Simple deployment
It’s a good balance between simplicity and reliability compared to full message brokers.
- Delayed jobs
- Job priorities
- Visibility timeouts
- Metrics and monitoring
A minimal, practical implementation of a multiple producer / multiple consumer job queue using Redis.
Designed for clarity, correctness, and learning distributed systems fundamentals.