This API Gateway project implements three load balancing strategies: Least Connections, Round Robin, and Weighted Round Robin. It features caching, rate limiting, and health checks to enhance the performance and reliability of backend service requests.
- Load Balancing: Implemented three strategies:
- Least Connections
- Round Robin
- Weighted Round Robin
- Caching: Uses Redis for caching responses to improve response times for repeated requests.
- Rate Limiting: Limits the number of requests to prevent abuse and ensure fair usage.
- Health Checks: Regularly checks the health of backend services to route requests only to healthy instances.
- API Forwarding:
- HTTP Requests: Uses Axios to forward HTTP requests.
- WebSocket: Handles WebSocket connections for real-time communication.
Before running the API Gateway, you need to start the backend servers.
- Navigate to the multibackend folder.
- Run the backend servers using the following commands:
cd multibackend
cd backend_1 # go to every backend folder backend_1, backend_2, and backend_3
node src/server.js # This will start backend_1, backend_2, and backend_3
cd Gateways
cd 'gateway ws' #GO to one folder gateway apis this is for apis request forwarding or gateway ws this is for websockets request forwarding
npm run dev
After all this send the request to gateway api like normal requests.