Implement layer 4 load balancer using Ha Proxy to serve two nodejs app servers.
Install the following requirements for before proceeding to the app installation
- Copy haproxy configuration file and paste it in your haproxy configuration file ('/etc/haproxy/' on linux).
- Reload haproxy service. On linux, use
sudo service haproxy reload
.
Navigate to your project folder on local machine and execute the following command from your terminal to clone the repository into your current directory locally.
git clone https://github.com/ahmedmeshref/load-balancer.git
From your terminal, install all dependencies needed by executing npm install
.
From your terminal, run the application with npm start
. Two Application instances are going to be created. App can be accessed on http://localhost:8888.
Note: You should have python installed alongside with the requests library to perform this task.
Run the python script req.py, which sends 1000 requests to the application. Ha Proxy will use the two app servers interchangeably.