Skip to content

A program which makes the connection between clients and servers using Consistent Hashing.

Notifications You must be signed in to change notification settings

tudor-cretu/Load-Balancer

Repository files navigation

Copyright Cretu Mihnea Tudor 315CAa 2022 - 2023
2nd Homework for Data Structures and Algorithms, Year I - Faculty of Automation Control and Computer Science, Polytechnic University of Bucharest

Load Balancer


1) Introduction


This program implements a Load Balancer which makes the connection between clients and servers using Consistent Hashing method. Consistent Hashing is a distributed hashing scheme that operates independently of the number of servers or objects in a distributed hash table. It powers many high-traffic dynamic websites and web applications. (according to Toptotal )

2) Usage


  • add_server [id] - adds a server with the given id in the on the load balancer and redirectes
  • store [key] [value] - stores the given key-value pair on the server with the corresponding hash
  • retrieve [key] - retrieves the value of the given key from the server with the corresponding hash
  • remove_server [id] - removes the server with the given id from the load balancer

  • 3) Examples


  • Input:

    -->add_server 0

    -->add_server 1

    -->add_server 2

    -->store "c674390f9" "Keyboard"

    -->store "a3529213e15" "Headphones"

    -->store "5a51719f5ec" "Router"

    -->store "2fe5f9f583" "Laptop"

    -->retrieve "c674390f9"

    -->retrieve "2fe5f9f583"

    -->remove_server 2

    -->retrieve "2fe5f9f583"


  • Output:

    Stored Keyboard on server 0.

    Stored Headphones on server 1.

    Stored Router on server 2.

    Stored Laptop on server 2.

    Retrieved Keyboard from server 0.

    Retrieved Laptop from server 2.

    Retrieved Laptop from server 1.


    4) Architecture


    The program is divided into 4 main parts:

    • main.c - contains the main function and the functions for parsing the input and calling the functions from the other files
    • hashtable.c - contains the functions for creating and managing the hash table
    • server.c - contains the functions for managing the servers, with each server being a hashtable
    • load_balancer.c - contains the functions for managing the load balancer, which makes the connection between the clients and the servers, redistributes keys and values between the servers if a new server is added or removed

    Each file has a header file with the declarations of the functions and the structures used in the respective file.



    ||| For more information regarding the functions purposes and their arguments, check the comments in the header(.h) files.

    ||| For more information regarding the implemenation of each function, please check the comments in .c files.

  • About

    A program which makes the connection between clients and servers using Consistent Hashing.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published