This project implements a message queuing system built with FastAPI, Redis, and WebSockets. The system allows asynchronous communication between producers (clients sending messages) and consumers (workers processing messages) using Redis as the message broker and WebSockets for real-time communication.
- Producer-Consumer Architecture: The system follows a classic producer-consumer model where messages are produced and consumed asynchronously using Redis.
- Redis Queue: Redis is used to implement a queue where messages are stored and processed in a First-In, First-Out (FIFO) order.
- WebSocket Communication: Real-time bidirectional communication between the client and the server is handled using WebSockets, allowing for immediate updates once messages are processed.
- Asynchronous Processing: FastAPI’s asynchronous capabilities allow for scalable and non-blocking processing of messages, making the system suitable for high-performance use cases.
- Producers: Clients connect via WebSocket and send messages to the server.
- Redis Queue: Messages are pushed into a Redis queue. Redis acts as a broker, holding the messages until they are consumed.# FastAPI Message Queuing System w/ Redis and WebSockets 📩 📨 📤
This project implements a message queuing system built with FastAPI, Redis, and WebSockets. The system allows asynchronous communication between producers (clients sending messages) and consumers (workers processing messages) using Redis as the message broker and WebSockets for real-time communication.
- main: Implements Message Queuing using Redis Pub/Sub
- redis-queue: Implements Message Queuing using Redis Queue
- Producer-Consumer Architecture: The system follows a classic producer-consumer model where messages are produced and consumed asynchronously using Redis.
- Redis Queue: Redis is used to implement a queue where messages are stored and processed in a First-In, First-Out (FIFO) order.
- Redis Pub/Sub: Implements a real-time messaging system where published messages are instantly delivered to active subscribers without being stored. It’s ideal for broadcasting but lacks message persistence and delivery guarantees.
- WebSocket Communication: Real-time bidirectional communication between the client and the server is handled using WebSockets, allowing for immediate updates once messages are processed.
- Asynchronous Processing: FastAPI’s asynchronous capabilities allow for scalable and non-blocking processing of messages, making the system suitable for high-performance use cases.
- Producers: Clients connect via WebSocket and send messages to the server.
- Redis Pub/Sub: Messages are published to a Redis channel, and Redis acts as a broker, instantly delivering messages to all active subscribers.
- Consumers (Subscribers): The system includes subscribers that listen to the Redis channel, process the messages in real-time, and handle the result.
- WebSocket Notifications: Once a message is processed, the result is sent back to the client through WebSocket in real-time.
- Producers: Clients connect via WebSocket and send messages to the server.
- Redis Queue: Messages are pushed into a Redis queue. Redis acts as a broker, holding the messages until they are consumed.
- Consumers (Workers): The system includes workers that pull tasks from the Redis queue, process them, and return the result.
- WebSocket Notifications: Once a message is processed, the result is sent back to the client through WebSocket in real-time.
python -m venv venv
source ./venv/bin/activate
Run FastAPI Command
- Consumers (Workers): The system includes workers that pull tasks from the Redis queue, process them, and return the result.
- WebSocket Notifications: Once a message is processed, the result is sent back to the client through WebSocket in real-time.
python -m venv venv
source ./venv/bin/activate
Run FastAPI Command