This Node.js project implements a rate-limiting and task-queuing system using Redis and Bull. The system dynamically creates separate queues for each user, applies rate limits (both per-second and per-minute), and processes tasks asynchronously.
- Per-User Task Queues: Each user has their own dedicated task queue created dynamically.
- Rate Limiting: Limits tasks to 1 per second and 20 per minute per user.
- Asynchronous Task Processing: Tasks are processed asynchronously without blocking other users.
- Redis-Backed: Uses Redis for both rate limiting and task queue storage.
- Node.js: JavaScript runtime used for backend development.
- Express.js: Web framework for building APIs.
- Redis: In-memory data store used for rate limiting and task queue management.
- Bull: Redis-backed job queue for handling asynchronous tasks.
- rate-limiter-flexible: Library used to implement flexible rate limiting rules
- dotenv: To manage environment variables.
Ensure that you have the following installed:
-
Clone the repository:
git clone <repository-url> cd <server>
-
Install dependencies:
npm install
-
Set up your environment variables by creating a .env file:
HOST=<Redis Host> PORT=<Redis Port>
-
Make sure Redis is running on your machine or point the .env to your Redis server.
-
Start the application:
node index.js