In the following article, we will discuss how to set up a Load balancer using our CDN. We will also look at some of the load balancing techniques and how to use them using our CDN.
What is Load Balancing?
Load balancing means distributing requests across multiple backend servers to avoid load on any one server at a given point in time. There are various load balancing techniques that you can deploy to balance web servers. Web servers can be hardware or software-based: hardware load balancers, some with propriety hardware, and software. Software load balancers can be deployed on your server.
Following are three techniques we use for load balancing
Round Robin
When multiple servers are connected in a cluster, the requests are sent sequentially to the servers. A single domain name is assigned to the servers connected to each other. Each of these servers is provided a unique IP address. The DNS has the list of all the IP addresses associated with the domain name. When a request for the domain name is incident on the load balancer, the load balancer sends the request to the cluster of servers in sequential order.
Least Connections
A server handles multiple network connections simultaneously. In this load balancing method, the load balancer forwards the HTTP request to the server handling the least connections in the cluster. This is determined by taking the computing capacity and the load of each server.
IP Hash
In this type of load balancing, the IP address is the determining factor of forwarding requests. With the help of an algorithm, the load balancer uses the source and destination IP address to generate a unique hash key. This key is used to establish a unique connection between a client and a server. If the user is disconnected, the user can reconnect to the same session on the server using the key. It is generally used when the user needs to connect to the same session after getting disconnected abruptly.
Load balancing using path mapping is provided as a feature in our CDN service. Using your dashboard, you can use the domain for which you would like to configure the load balancer. With the Path Mapping option, we can link the public path to the path at which the content is stored at the backend.
You can follow the below path to access the Path Mapping page.
Tools > CDN Main Page > Manage Domain > Manage > Traffic Manager > Path Mapping
Step 1
Clicking on the Path Mapping option, you will get a list of all the paths that you have mapped under the domain. Please click on the EDIT button to map the path. If you haven't mapped any domain, you can click on the +Add button to create a path.
Step 2
Once you click on the "Edit" or "Add" button, the following options will be listed on the page.
A) Domain - Select the domain from the dropdown list to add the path mapping
B) Select Location - Here, you need to select the domain's location to add a load balancer to. If you want to add a load balancer to the entire domain, please select '/'.
C) Host Header - You can set up the Host Header specifically for the chosen path. With the help of host headers, the web server can identify the traffic and send it to the right path.
D) Alias - You can choose between different aliases or create a new one. Please click on the "Create Alias" to create a new one.
Aliases are names given to a setup used to balance the traffic by choosing the different load balancing algorithms such as Round Robin, IP hash, and least connections. It would be best if you mentioned the Origin IP, Origin Port, weight, fail timeout, and max fails for the mentioned IP. For more information on how to create Alias, please visit https://www.psychz.net/client/kb/en/how-to-create-alias.html
Fields under Alias page
Origin IP: This is the origin IP address of the domain
Origin Port: Here, you need to add the port address of the domain you wish to add the Alias.
Weight: The weight is relevant when there are two or more backend/origin servers. The one with weight 2 receives twice as many requests as the one with weight 1 does.
Fail Timeout: Time frame in seconds before the connect declares as a failed attempt.
Max Fails: Maximum number of failed attempts.
Once a load balancer is added - it can be linked to a particular URL within the domain for which it was configured. The content for the URL can be pulled from this specific load balancer (backend servers within this load balancer). This process is called path mapping and can be done from your dashboard: https://www.psychz.net/dashboard/client/web/cdn/pathmapping/719