Coder Social home page Coder Social logo

load-balancer's Introduction

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.

  • load-balancer's People

    Contributors

    tudor-cretu avatar

    Watchers

     avatar

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.