This project demonstrates a simple reverse proxy and backend cluster setup using Node.js and Express. It includes a multi-backend server cluster, a reverse proxy with health checks and load balancing, and a load testing script.
- Multi-backend server cluster: Spawns multiple backend Express servers on different ports using Node.js clustering.
- Reverse proxy: Forwards incoming requests to healthy backend servers using round-robin load balancing.
- Health checks: Automatically checks backend health and removes unhealthy servers from the rotation.
- Load testing: Uses
autocannonto benchmark the proxy and backend cluster.
multi-backend-server.js: Launches a cluster of backend Express servers on ports 5001, 5002, ...multi-servers.js: Implements the reverse proxy server on port 3000, with round-robin load balancing and health checks for the backends.load-test.js: Runs a load test against the reverse proxy usingautocannon.package.json: Project dependencies and scripts.
npm installnode multi-backend-server.jsnode multi-servers.jsnode load-test.js- The backend cluster (
multi-backend-server.js) launches several Express servers on sequential ports (default: 5001+). - The reverse proxy (
multi-servers.js) listens on port 3000 and forwards requests to healthy backend servers in a round-robin fashion. It checks/healthendpoints on each backend every 5 seconds. - The load test script (
load-test.js) usesautocannonto benchmark the proxy.
Note: This project is for educational/demo purposes and is not production-hardened. For advanced use cases, consider using established reverse proxy solutions like NGINX or HAProxy.