Author: BIRLEANU TEODOR MATEI Year: 2023
This project implements a Load Balancer using consistent hashing to manage servers and distribute data. The load balancer is designed to handle server addition, removal, and efficient key-value storage and retrieval across multiple servers.
- The load balancer uses a consistent hashing algorithm to map keys and servers onto a circular hash ring.
- Each server has three replicas to ensure even data distribution.
- Adding Servers:
- Servers are added to the hash ring along with their replicas.
- Data is redistributed to maintain consistent hashing properties.
- Removing Servers:
- When a server is removed, its data is redistributed to the next server in the hash ring.
- Storage:
- Keys are hashed and mapped to a server using consistent hashing.
- Data is stored in the server's hashtable.
- Retrieval:
- Keys are hashed and located on the appropriate server for retrieval.
- If the key does not exist,
NULL
is returned.
- When servers are added or removed, the load balancer ensures data redistribution without disrupting the system.
hash_function_servers
: Hashes server IDs to place them on the hash ring.hash_function_key
: Hashes keys to determine their position on the ring.
- A binary search is used to efficiently locate the position of servers and keys on the hash ring.
- Each server is represented by three replicas on the hash ring for load balancing and fault tolerance.
- Each server has its own hashtable to store key-value pairs.
load_balancer *init_load_balancer();