Design a simple load balancer for Google.com. What data structures would you use?
- Whitney Chard
Why do we need a load balancer?
- High availability
- Even distribution
- Less stress on the nodes
- Healthy system
“Simple load balancer” – The simplest load balancer strategy would be round robin and least connection used.
Since @hjc explained on round-robin, I have taken the least connection
How does it work?
- The least connection strategy, checks which server is free based on the number of active connections the server is serving.
- The server will be notified about this information through a health check/notifying mechanism like regular ping or pull model to see the active connection
Data Structure Used:
- Round robin kind a uses linked-list
- The least connection algorithm can use a combination of.
- Hashmap which will store the server id, number of connection
- The heap sort data structure can be used to identify the root node
- The max heap will store the server with the least connection
- The min heap will store the server with a max open connection
- This is anyways in sorted order, so we could identify the server that can handle the request
In reality, there is a combination of strategy, ideally by load balancer (to distribute traffic across network) and CDN to distribute content based on geography for faster response time solves the availability problem

Google
Amazon