📜 ⬆️ ⬇️

vCloud Director for the smallest (part 3): setting up a load balancer

Hello!

Today we will learn how to configure a load balancer (Load Balancer) in the vCloud Director control panel, which is used in the CloudLITE.ru IaaS service.

As the name suggests, this tool balances the web resource traffic between multiple servers using a given algorithm and protocol. Since the load is distributed between servers that perform the same function (for example, a web server), when one of the servers fails, the load is redistributed among the remaining servers. Thus, the balancer increases the site resiliency. In general, the thing is useful for sites that are hosted in the cloud, especially for online stores.
')
image

How does it work?


The load balancer function in the vCloud Director panel is performed by vShield Edge . This service works as an address translator (NAT), it is configured Firewall, VPN, DHCP and static routing.
To make it work, when setting up, we register the following:

Pool Servers - IP addresses of servers (virtual machines) between which the load is balanced. At the same step, we will specify the protocol (HTTP, HTTPS, TCP) through which the balancer accesses the servers, and the parameters for tracking the availability of virtual machines. Based on this monitoring, a decision will be made to redirect traffic to a running server in the event of a failure.

Virtual Servers (Virtual IP) - external IP-address through which users get access to resources hosted on virtual machines (Pool Servers).
Below is an approximate scheme of how it might look for a conditional site.

image

Instruction


We proceed to the setting. At the start we will need:

- vShield Edge to which the external network is connected.

- a network of organization level, in which there are at least two virtual machines (sorry for captaincy :)).

In CloudLITE.ru, all this is created automatically, but if you use a vCloud Director somewhere else, here are the detailed instructions for setting up the network.

- external IP-address or their range. You can see this in the vShield Edge properties . In our case, this is 92.242.44.150. We recorded it somewhere.

- internal IP of virtual machines that will participate in balancing. To do this, go to the My Cloud tab, open the vApp with the necessary VMs. We look for the necessary information in the corresponding column.

image

So, let's go set up:

1. Go to the Administration section and click on the virtual data center.

image

2. Go to the Edge Gateways tab. Right click on Edge and select Edge Gateway Services .

image

3. In the new window, go to the Load Balancer tab. First you need to add a pool of virtual machines (servers) between which we will balance the load. To do this, click on the Pool Servers and click Add .

image

4. We register the name of the pool and its description, if necessary.

image

5. Next, choose which server will be available (HTTP, HTTPS, TCP), ports and balancing method, i.e. algorithm according to which traffic will be distributed between virtual machines. The following methods are available:

- IP Hash : all requests from the same IP address will go to the same server from the pool
- Round Robin : requests are distributed in turn between servers, depending on the given weight.
- URI : all requests to the same address will be sent to 1 virtual machine. Applicable only to servers accessible via the http protocol.
- Least Connected : a new request will be sent to the least loaded server.
For example, choose the protocol http, Port 80, method Round Robin.

image

6. At the next stage, we set the parameters by which the availability of servers of this pool will be monitored:
- port
- protocol
- interval between calls (interval)
- the interval during which the response from the server should be received (timeout)
- the required number of successful hits (health threshold)
- admissible number of unsuccessful requests before the message about server failure (unhealth threshold).

Here you can tweak the default values, the main thing is not to overdo it and not set, for example, for the timeout field for 1 sec. :)

In the URI for HTTP service field, we indicate the address at which the balancer will check the server status. You can leave it as is (/). If you are not looking for easy ways, you can create a static web page for each server. In this case, a 200 OK response means that everything is working.

image

7. Next, add the IP addresses of virtual machines (Members) to the created pool. To do this, click Add and enter the IP addresses of the machines between which the balancing will be performed in the appropriate field. For example, 192.168.1.2 and 192.168.1.3.

In Ratio Weight specify the weight of the server in balancing. If for the first server we specify the weight 1, and for the second 2, then the second server will receive 2 times more hits.
If you put 0 - the server will not participate in balancing.

image

Add a second virtual machine and click Next.

image

8. On the Ready to Complet e tab, check everything again and click Finish .

image

9. Return to the original page and go to the Virtual Servers tab. Click Add .

image

10. Register the name of the virtual server.
- in the field Applied On select the network (external!). In our case, this is cloudlite-internet-2.
- we assign the IP address from the Sub-Allocated IP Pool (the one we watched here )
- Select the server pool created in the previous step.
If there is a need for each client to get to the server on which he accessed the first time, select the Persistence Method Cookie. When everything is added, click OK.

image

11. Do not forget to click OK on the main page.

With the balancer all. If you haven’t set up a Firewall before, then you should do it - list the rules for it in such a way that it allows the necessary traffic to pass (see the detailed instructions here ).

I hope this tool makes life easier for you and visitors to your web resource. If you have any questions, ask in the comments. And go to CloudLITE.ru to feel everything with your own hands;)

Source: https://habr.com/ru/post/260597/


All Articles