-
Set up a new server instance (virtual machine or physical server) to act as the load balancer.
-
Install NGINX on the load balancer server:
sudo apt-get update sudo apt-get install nginx
-
Open NGINX configuration file:
sudo nano /etc/nginx/nginx.conf
-
Update the
http
block to include the upstream servers:http { upstream my_servers { server backend_server1_ip; server backend_server2_ip; server backend_server3_ip; } # ... (other configurations) server { listen 80; location / { proxy_pass http://my_servers; } } }
-
Replace
backend_server1_ip
,backend_server2_ip
, andbackend_server3_ip
with the actual IP addresses of your backend servers. -
Save the configuration and restart NGINX:
sudo service nginx restart
-
Create multiple backend servers (e.g., using virtual machines or separate physical servers).
-
Install NGINX on each backend server:
sudo apt-get update sudo apt-get install nginx
-
Copy the cafe website HTML files to each backend server:
scp -r /path/to/local/cafe-website/html user@backend_server_ip:/path/to/remote/cafe-website/
-
Ensure NGINX is configured to serve the cafe website. Update the server block in
/etc/nginx/sites-available/default
or create a new configuration file:server { listen 80; server_name backend_server_ip; location / { root /path/to/remote/cafe-website/html; index index.html; } }
-
Save the configuration and restart NGINX:
sudo service nginx restart
-
Open a web browser and navigate to the IP address of the load balancer server (or the domain if you have one):
http://load_balancer_ip
-
NGINX on the load balancer will distribute requests among the backend servers.
-
To test load balancing, use tools like Apache Benchmark (
ab
) from the load balancer server:ab -n 1000 -c 10 http://load_balancer_ip/
-
Adjust the number of requests (
-n
) and concurrency (-c
) based on your testing needs.
Contributions are welcome! If you find any issues or have suggestions, please open an issue or submit a pull request.