This Node.js project implements a simple application load balancer that uses a round-robin algorithm to distribute incoming requests among multiple target servers. Additionally, the load balancer performs health checks on the target servers to ensure that only healthy servers receive incoming traffic.
-
Round Robin Load Balancing: Incoming requests are distributed among target servers in a round-robin fashion, ensuring even utilization.
-
Health Check: The load balancer performs periodic health checks on each target server to determine its availability. Unhealthy servers are temporarily excluded from the rotation.
-
Multi-Process Setup: The load balancer can take advantage of multiple CPU cores using the Node.js Cluster module, creating separate worker processes for each core.
- Node.js: Make sure you have Node.js installed on your machine. You can download it here.
-
Clone the repository:
git clone https://github.com/your-username/load-balancer.git
-
Navigate to the project directory:
cd load-balancer
-
Install dependencies:
npm install
-
Update the
targets
array inindex.js
with the details of your target servers. -
Start the load balancer:
npm start
-
Access your application through the load balancer at
http://localhost:8000
.
- You can adjust the health check interval and other settings in the
index.js
file.
Contributions are welcome! Please follow the Contribution Guidelines.
This project is licensed under the MIT License.