Posts

A quick overview of Amazon ELB

Updated: Apr 29




You might have heard of the word "ELB", but do you clearly understand what it is and how it works? Today, I will briefly explain ELB, a load balancer that AWS provides. I hope this blog post helps you understand a general idea of ELB. Let's get started!


 

What is Load Balancer?


A load balancer is a system that balances (distributes) a load of a server. You might think you do not need to use a load balancer if you do not have a ton of access and the server handles only a few requests. However, I am pretty sure that many of you have experienced that your server becomes heavy and it takes a long time to display your contents when there is a concentration of access to your server for some reason.


When a server is accessed from the Internet, it uses its resources such as CPU and memory to process the request. Thus the web user's browser will display the page slowly or not at all when the number of requests increases dramatically due to a concentration of accesses. This is when a load balancer shines.


A load balancer plays an active role in preventing the heavy loading of a website due to a high load state. It prevents the load from being concentrated on one server by distributing the load across to multiple servers. This system can provide stable service to web users not only in the case of web access concentration but also in the case of a server breakdown.


The state of the load on a server is not always constant. Therefore, it is necessary to install a load balancer in order to provide stable services to users at all times.



 

What is ELB?


ELB stands for "Elastic Load Balancing" and is a load balancer provided by AWS. As it is mentioned in the above section, a load balancer is a system that distributes access (traffic) which is concentrated on a server to multiple servers and networks to distribute the load.


An ELB also has a health check function. With this function, a user can monitor the performance of the servers in real-time. Thus when ELB finds an abnormal state or activity in a server, an ELB can avoid sending traffic to that server and send traffic to other servers with a normal state.


Furthermore, since an ELB automatically scales according to load conditions, administrators (engineers) do not need to manually increase the number of ELBs or increase their specifications.


In case of a sudden increase in access or other traffic rise is predicted, it can be used together with AWS Auto Scaling. This makes it possible to increase or decrease the number of servers in accordance with the volume of requests, thereby it can prevent servers to be down.


Another feature of ELBs is that they can balance traffic across EC2s even when they are in different availability zones.


It is recommended that you enable multiple availability zones for all load balancers. In fact, the Application Load Balancer (ALB), a type of ELB, requires at least two availability zones to be enabled. With this setting, an ELB can route traffic to a valid target in a valid availability zone if the other availability zone becomes unavailable or no longer has a valid target.


How ELB works



 

Types of ELBs

  • Application Load Balancer (ALB)

A single load balancer optimized for HTTP and HTTPS that runs at the application layer in the OSI reference model. It is the most used load balancer for web applications. Since it makes decisions by looking at the contents of the request command and other instructions, it can balance traffic by the directory unit of the destination URL. ALB can also encrypt the communication between the instance and the ALB itself.

In addition, a user can specify an IP address as the traffic destination.

  • Network Load Balancer (NLB)

NLB is a newer type of load balancer designed to handle millions of requests per second while maintaining high productivity with low latency. It works at the transport layer (the layer responsible for controlling the transmitted data) in the OSI reference model. Since it only looks at packets, NLB cannot balance traffic as detailed as ALB. Instead, a user can set a static IP address as the traffic destination, or you can set the IP address of the client accessing the server to be passed directly to the server. NLB has features that it routes traffic to a target within a VPC and handles millions of requests per second while maintaining low latency. Therefore, it is suitable for servers that are expected to receive a large amount of access which means a sudden increase in load.

  • Classic Load Balancer (CLB)

CLB is an older type of load balancer among ELBs. It supports a large number of protocols such as TCP, SSL/TLS, HTTP, HTTPS, and more. CLB provides basic load balancing across multiple EC2 instances and works at both the request and connection levels. Its weakness is that it cannot be configured in a complex way, and is currently not recommended by AWS for use as a load balancer.

  • Gateway Load Balancer (GLB)

The latest ELB which was released recently. Gateway Load Balancer is developed to easily deploy, scale, and run third-party virtual network appliances. The Gateway Load Balancer provides load balancing and Auto Scaling to a fleet of third-party appliances, making it transparent to the source and destination of traffics.

This makes it ideal for working with third-party appliances for security, network analysis, and other use cases.


Elastic Load Balancing



By the way, when I verified about ALB for writing this blog post, only tying ALB to the verification instance returned a "403" status code to me.


172.31.4.72 - - [15/Jul/2021:07:59:03 +0000] "GET / HTTP/1.1" 403 4897 "-" "ELB-HealthChecker/2.0"

So, I placed an "index.html" file under the document root, put the words "aws test" in the file, and then accessed the file from a browser, the "200" status code was returned successfully.

*It is a prerequisite that you have apache installed on your server.


First, go to the document root.


[root@ip-172-31-38-25 httpd]# cd /var/www/html


Create a file called "index.html".


[root@ip-172-31-38-25 html]# touch index.html


Write "aws test" in the "index.html" file you created.


[root@ip-172-31-38-25 html]# vi index.html


If you want to access the verification instance from a browser, you can do so by typing the public IPv4 address in the search bar of the browser.


Let's check the access log again!


172.31.4.72 - - [15/Jul/2021:08:38:35 +0000] "GET / HTTP/1.1" 200 9 "-" "ELB-HealthChecker/2.0"

The status code was successfully changed to 200, and when I checked the "Target Group" from the AWS console, the status of the "Target Group" also changed from Unhealthy to Healthy!


 

Summary


A load balancer is like a boss in a company that decides who does what. By using a load balancer well, you can prevent server downtime and solve problems such as site display delays or sites not being displayed, which will increase trust in your site!






This blog post is translated from a blog post by Haruka Inoue on Beyond Co..

88 views