Load balancing is a technic of distributing load traffic -such as network traffic- to prevent the data loss, and thereby to improve the system security. So basically it is a feature which gathers traffic data from a cluster of servers or network equipment, and distribute it to another cluster with a pre-configured load balancing algorithms.
The most used industry standard algorithms are branched into two categories:
Least connection: Allows to check the servers with the fewest connections open, and sends the loaded traffic to those servers.
Weighted least connection: It is a 'least connection' algorithm but the difference is that the connection weight is assigned with the operator manually.
Weighted response time: Allows to send the traffic to related servers with the quickest response according to the calculation of each server's response time.
Resource-based:Sends the traffic according to the CPU and memory usage of servers at that moment.
Round robin: Allows to distribute traffic to a cluster of servers, virtual machines or network equipment by using Domain Name System (DNS) records.
Weighted round robin: It is a 'round robin' except the weight of each server is configured manually by the operator.
IP hash: Combination of source and destination IP addresses decides where the connection is assigned next. This combination is calculated with a mathematical function to convert it to an IP hash.
If we understood the load balancing and its main algorithms, then we can start talking about what a load balancer is. It is a device which supports all of these features mentioned above. An LB is generally grouped as Layer-4 (L4) or Layer-7 (L7) due to the networking protocols it uses.
L4 load balancer acts with network and transport layer protocols, such as IP, TCP, UDP and FTP. Meanwhile L7 load balancer works with application layer protocols, such as HTTP/HTTPS.
The concept has a bit more features on the cloud side. The main difference is the elasticity. So it is now called 'Elastic Load Balancing' on AWS. As the official document says, 'Elastic Load Balancing automatically distributes your incoming traffic across multiple targets…', therefore different types of load can be forwarded into various kinds of instances.
Before diving deep in the AWS ELB products, let's find out what the cloud-based load balancer benefits are. First of all, it allows to increase the data protection and prevent any kind of data loss. It is important especially when the flow contains sensitive data. Secondly, it has the elasticity and flexibility to enhance its fault-tolerant architecture. Adding or removing a load balancer is as easy as pie. You can manage your incoming traffic into a single or multiple Availability Zones without disrupting the flow. Also this main feature enables to handle high throughput including a suddenly increased traffic patterns. Third one is about configuring health checks to monitor the status of the resources. With this feature, the load balancer understands which path is healthy and which one is not. And finally, the capability of cloud-native working environment helps to ease cloud migration. This is very important because it exhibits the product's difference compare to the traditional load balancers.
So what are AWS Elastic Load Balancer types?
- It works on Layer-7 which is the Application Layer of OSI (Open Systems Interconnection) model. So the most used protocols are HTTP, HTTPS and gRPC.
- It receives a request from the traffic resource, then evaluates some rules -called listener rules- to decide which action should be taken.
- Default routing algorithm is round robin. However it can be specified as the least connection routing algorithm later.
- It is a Layer-4 load balancer which is working on Transport Layer according to OSI model. TCP and UDP are widely used protocols in L4 traffics.
- It is able to handle millions of requests per second in this layer. For UDP traffic, the LB selects the target path by using hash algorithm, source/destination IP addresses and ports. For TCP traffic, the LB selects the correct target as same parameters as UDP, but also TCP sequence number does effect the selection.
- It works partially on Layer-3, which is the Network layer of OSI model. This means that it listens the entire traffic for all IP packets on each port. L3 part is the Gateway itself, while L4 part is the main load balancing operation.
- It is mostly used to deploy and manage network-related virtual applications with easy integration function of 3rd party appliances.
- A classic load balancer's logic is very similar to the widely used ones in fixed telecom networks. It simply distributes the incoming traffic across multiple EC2 instances in multiple Availability Zones. It detects unhealthy instances or target path, then forwards the incoming flow to only healthy instances.
- It works on both L4 and L7, but this does not mean that it is the best option to choose. It is highly recommend to use specific load balancers for an exact purpose.
For more about AWS Elastic Load Balancing, you can dive deep into the documentation here.
Thanks for reading!