-
Notifications
You must be signed in to change notification settings - Fork 0
The Load Balancer
It is a multithreaded application that needs hardware support for minim three thread: receiving packets, counting time, and sending a response. The load balancer is designed to communicate with two servers.
It runs on a separate machine, having an IP address for connections with servers.
The program implementation can be find in headers/common/CLoadBalancer.h
and sources/common/CLoadBalancer.c
and it consists in sending packets to two main servers.
The load balancer communicates with servers via layer 4 protocol TCP thus in the first process of initialization, it verifies connections with servers through sockets. So, the load balancer has in its internal structure data with information that contains IP addresses of each server. For a successful connection, servers must be turned on before load balancer starts. The IP addresses can be find in header/common/ConnectionDetails.h
.
In the project, a custom algorithm was implemented, which is based on spreading packets to servers, such that the first available server receives the packet even if the other is empty. The method describing this implementation is called int findAvailableStation()
which verifies the load of every server and it returns the server index which can handle the packet.
If there is no server available, the packet will be added to a local storage space named QUEUE
. It also has a limited storage space QUEUE_SIZE
of packets, the number is set to 4
packets. If there is no space available, it will consume the packets from local storage and after it will continue its task.
The process of processing packets comes from a method called addPackets(int val)
, which describes the number of generated packets. The val
variable can be as large as you want, it is in capabilities of load balancer handle any number of packets.
The user interface is developed with the help of Sciter and it runs on a different process, that allows running both the processing / generating packets and showing the interface.
Every 10 seconds, the user interface calls two functions in order to retrieve the status of the load balancer and the servers, at a time. Those functions return serialized data as strings, which are deserialized at the interface layer, using TIScript, and then injected into the elements from the interface.
In Makefile
, there is a target for building the load balancer.
make build_load_balancer
Name | Type | Link |
---|---|---|
Sciter | cross-platform UI development library | website |