Skip to content
This repository was archived by the owner on Feb 10, 2021. It is now read-only.

The Load Balancer

Iosif George Andrei edited this page Jun 12, 2020 · 3 revisions

Description

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.

Screenshots

Load Balancer User Interface

Load Balancer Logs

Implementation

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.

Effective Load Balancer

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.

Packet Generation

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.

User Interface

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.

How to Build

In Makefile, there is a target for building the load balancer.

make build_load_balancer

Resources

Name Type Link
Sciter cross-platform UI development library website
Clone this wiki locally