Load Balancing Flashcards
What is load balancing?
Distributing the heavy traffic across servers running in the cluster using different algorithms
What is DNS Querying?
When the user types in the url of the website, this is called DNS Querying
4 key components of DNS Infrastructure
- DNS Recursive Nameserver/DNS ReSolver
- Root NameServer
- Top Level Domain Server
- Authoritative Nameserver
DNS Querying Flow
- Browser -> DNS Resolver ( Search for amazon.com)
- DNS Resolver -> Root Nameserver( Tell me the IP address of the Top Level Domain Server that hosts the .com domain)
- DNS Resolver -> Top Level Domain Name Server ( tell me the IP address of the Authoritative Server that has amazon.com hosted in it)
- DNS Resolver-> Authoritative Server( Tell me the IP address of amazon.com)
- DNS Resolver-> Browser
what is DNS Level Load Balancing?
- DNS Load balancing is set up at the Authoritative server level.
- DNS load balancingenables theauthoritative serverto return differentIP addressesof a certain domain to the clients. Every time it receives a query for anIP, it returns a list ofIP addressesof a domain to the client.
With every request, theauthoritative serverchanges the order of theIP addressesin the list in around-robinfashion.
When another client sends out a request for anIP addressto theauthoritative server, it re-orders the list and puts anotherIP addresson the top of the list following theround-robin algorithm( Round Robin DNS Load balancing)
Limitations of DNS Load Balancing
- Majorly used by companies to distribute traffic across multiple data centers.
- It doesn’t take into account the existing load on the cluster, the content they hold, their request processing time, and their in-service status.
- Since the IP addresses are cached, there is always a possibility of requests being routed to out of order machine.
- It does have some limitations but this is the cheapest way of setting up LB.
3 modes of load balancing
- DNS Load Balancing
- Hardware Based Load Balancing
- Software Based Load Balancing
What is hardware-based Load Balancing?
- High-performance physical hardware with a specialized operating system that distributes web application traffic across a cluster of application servers
- Distributes the load on the basis of existing open connection, compute utilization, and several other parameters.
- They need regular maintenance and upgrade.
- Expensive to setup
- They are preferred for their top-notch performance.
What is software-based load balancing?
- It can be installed on commodity hardware and VMs
- More cost-effective and easy to work with.
They are pretty advanced in terms of metrics used to distribute the load(Source IP, Cookies, HTTP Headers, CPU & Memory Utilization , load on N/W)
They even perform cont. health checks on servers to keep an updated list of in-service machines.
E.g HAProxy
What are the different algorithms used in Load balancing?
- Round Robin
- Weighted Round Robin
- Random
- Least Connections
- Hash
What is Round Robin Load Balancing Algorithm?
No parameters e.g CPU/Memory utilization are taken into consideration
What is weighted Round Robin Load Balancing?
Based on the server’s compute and traffic handling capacity. And then round-robin.
This very useful when the applications are deployed across different data centres with different capacities.
What is the Least Connections Load Balancing?
The traffic is routed to that machine that has the least open connections among all the machines in the cluster.
Just the Least connection doesn’t give a perfect picture of what’s going on each server.
The possibility that machines having the least amount of open connection might be processing requests demanding more CPU and compute power.
Machines with less request processing time, CPU utilization & simultaneously having the least open connections are the right candidates to process the future client requests.
This approach comes in handy when servers have long opened connections. e.g Persistent Connections in Gaming Application
What is random Load Balancing?
The load balancer may also find similar servers in terms of existing load, request processing time and so on and then it randomly routes the traffic to these machines.
What is Hash-Based Load Balancing?
- The source IP of the request and request URL is hashed to route the traffic to backend servers.
- This ensures Session Persistence
- This results in a better User experience as the request always goes to the server which has the processed data in its memory. There is no need to fetch client session data from the session memory of the cluster and then process the request. This reduces latency.
- Hashing a URL ensures that a request with a specific URL always hits a certain cache that already has data. This ensures that there is no cache miss
- This also avoids the need for duplicating data in every cache. An efficient way of implementing Cache.