{{tag>projects cloud club computing virtualization machines VMs AWS Azure GCP}} [[cloud_club|About the Club]] ==== Cloud Club Topics - Webserver & LoadBalancer ==== ==== Install a webserver ==== - What is a webserver? - What makes a server a webserver? - What is a load balancer ( LB )? - What does the load balancer do? ==== Understanding webservers ==== - A webserver is a computer ( any computer will do ) that has some webserver software installed on it. - Examples of webserver software: ^ Name ^ Supported OS ^ | httpd/apache2 ( apache ) | Runs on Linux, Windows, Mac | | nginx | Runs on Linux, windows, Mac | | Internet Information Server ( IIS ) | Windows ( server & workstation ) | | Tomcat ( Java ) | Linux, Windows, Mac | | Lighttpd | Linux, Windows ( experimental ), Mac | ==== Hands-on installing a webserver ==== - Create a debian server ( if you don't already have one ) - Assign an IP address from your range - Install sudo ( elevated privileges for other commands ) - don't forget to replace with your username su - apt install sudo -y usermod -aG sudo exit - Install httpd ( webserver software ) sudo apt install apache2 -y sudo systemctl enable --now apache2 sudo systemctl status apache2 ==== Hands-on configure a webserver ==== - A default configuration is already setup - Edit the default page ( /var/www/index.html ) My 1st Page!

Mike D

This is awesome!

- View your page in your browser - View your page with curl ( replace with the IP of your server ) curl http:/// ==== Understanding Load Balancers ( LB ) ==== - Load balancers are placed logically in front of the webservers - They take the requests from the clients ( browsers ) and apply rules ( drop, redirect, forward, etc ) - A typical LB will have multiple webservers ( called "backends" or "real servers" ) as targets - Techniques or methods of LBs - Round robin - Distributes requests sequentially to each server in a pool. - Simple to implement and understand. - Doesn't consider server load, so it might not be ideal for servers with varying capacities. - Least connections - Directs new connections to the server with the fewest active connections. - Can improve response times by ensuring servers with fewer connections are utilized more effectively. - Liquid Web notes that this approach is often the default and provides good performance. - IP hash - Routes requests to the same server based on the client's IP address. - Useful for maintaining session affinity, where a client should always connect to the same server for their session. - Weighted round robin - Similar to Round Robin but assigns different weights to servers based on their capacity. - Progress Software mentions that this is a good option when servers have varying capabilities. - Least response time - Chooses the server with the least average response time and the fewest active connections. - Lavelle Networks notes that this method prioritizes both response time and server load. - Random - Distributes requests randomly across the available servers. - F5 notes that it's a simple method but may lead to load imbalances. - Resource-based ( adaptive ) - Makes load balancing decisions based on status indicators from each server, allowing for more detailed health checks. - Kemp Technologies mentions that this method is suitable for applications with varied workloads. - URL hash - Routes requests to servers based on a hash of the requested URL. - Lavelle Networks notes that this is used when servers serve content that is unique per server. - Weighted least connections - Combines server capacity and current connections when distributing traffic. - Lavelle Networks notes that it prioritizes both factors for load distribution. - DNS-based load balancing - Uses DNS to route traffic to different servers. - Multiple IP addresses are configured in DNS for a single hostname, and DNS alternates the IP address returned to clients. - Geo-location based load balancing - Routes traffic based on the geographic location of the client. ==== Hands-on Load Balancers ( LB ) ==== - Create a Rocky Linux server ( if you don't already have one ) - Assign an IP address from your range - Install haproxy sudo dnf install haproxy -y - Add the following line to the bottom of /etc/haproxy/haproxy.cfg config file - ( replace with your server's IP address ) #--------------------------------------------------------------------- # Load balancer statistics ( stats ) #--------------------------------------------------------------------- listen stats bind :9000 mode http stats enable stats uri /stats #--------------------------------------------------------------------- # website frontend which proxys to the backends #--------------------------------------------------------------------- frontend website-frontend bind *:8080 default_backend website-backend #--------------------------------------------------------------------- # website backend for serving up packages #--------------------------------------------------------------------- backend website-backend balance roundrobin server website :80 check server website :80 check - View the website in your browser by going to the Load Balancer IP - View the website with curl ( replace with the IP of the LB ) curl http:/// - View the load balancer stats provided by HAProxy by going to the Load Balancer IP http://:9000/stats - The stats page will look similar to this. {{https://imgix.datadoghq.com/img/blog/how-to-collect-haproxy-metrics/stats-report.png?nocache}} - Optionally, you can install the Siege program to submit many requests. This will bump the numbers quickly # The 2 rpm files must be copied from the USB drive to the current directory sudo dnf install ./*.rpm -y siege -t1 http://:8080