[For AWS Beginners] A 5-Minute Guide to Amazon ELB!

table of contents
Hello! I'm Inoue, a Persian cat from Beyond Co., Ltd.'s Shikoku office
This time, I would like to explain about the load balancer provided by AWS!
What is a load balancer?
You may have heard of a load balancer, but simply put, it is a device that balances the load on a server
If there are not many accesses and the server processes only a few requests, there is no problem even if you do not use a load balancer. However, suppose that access to the server becomes concentrated for some reason
At times like these, many people have probably experienced the server becoming slow and the site taking a long time to load
When a server is accessed from the Internet, it processes the request using resources such as the CPU and memory installed on the device
If for some reason access becomes concentrated and the number of requests increases suddenly, the page may display slowly or not at all in the web user's browser. When request processing is delayed, such as when the page displays slowly or not at all, it indicates a high load
When access to the server is concentrated, the load is high
Load balancers are used to prevent sites from slowing down or even not displaying properly under such high load conditions
By distributing the load across multiple servers, you can prevent the load from concentrating on one server
The load balancer mechanism allows us to provide stable services to web users not only in the event of a surge in web access but also in the event of a server failure
The load on a server is not always constant, so in order to provide users with a stable service, it is necessary to introduce a load balancer
What is ELB?
ELB stands for Elastic Load Balancing and is a load balancer provided by AWS
As mentioned above, a load balancer is a system that distributes the load by distributing concentrated access (traffic) to multiple servers or networks. Because it distributes a single load, it is also called a "load distribution device."
In addition to load balancing, it also has a health check function, which allows you to monitor server performance in real time
This allows you to identify an abnormal server, stop sending traffic to that server, and send traffic to other healthy servers, thereby balancing the load
ELB automatically distributes the load and prevents servers from going down
Furthermore, ELB automatically scales according to the load, eliminating the need for administrators (engineers) to manually increase the number of ELBs or upgrade their specifications
If you anticipate a sudden increase in traffic, you can also use AWS Auto Scaling. This allows you to increase or decrease the number of servers according to the amount of requests, preventing server downtime
Another feature of ELB is that it can load balance traffic across EC2 instances even if they are in different availability zones
We recommend enabling multiple Availability Zones for all load balancers.
However, you must enable at least two Availability Zones for your Application Load Balancer.
This configuration ensures that your load balancer can continue to route traffic.
If one Availability Zone becomes unavailable or has no healthy targets, your load balancer can route traffic to healthy targets in another Availability Zone.
Reference site: How ELB works
■Types of ELB
There are three types of ELB: ALB, NLB, and CLB.
| ALB | It stands for "Application Load Balancer." It is a load balancer that is optimal for HTTP and HTTPS. It operates at the application layer of the OSI reference model. It is a single load balancer with enhanced support for HTTP and HTTPS protocols. It is the most widely used load balancer for web applications. It makes decisions based on the content of commands such as request commands, so it can also distribute traffic by directory in the destination URL. It is also possible to encrypt communication between instances and the load balancer. It is also possible to specify an IP address as the distribution destination. |
| NLB | NLB stands for Network Load Balancer. It operates at the transport layer (the layer responsible for controlling transmitted data) in the OSI reference model. Because it only sees fragmented data called packets, it cannot distribute traffic as precisely as ALB. Instead, you can set a static IP address as the distribution destination, or you can configure it to pass the IP address of the client accessing the server directly to the server. NLB is a modern load balancer designed to handle millions of requests per second while maintaining ultra-low latency and high throughput. NLB routes traffic to targets within a VPC and is capable of handling millions of requests per second while maintaining low latency. This makes it suitable for servers that are expected to receive a large amount of traffic (sudden increases in load). |
| CLB | This stands for "Classic Load Balancer." It is an older type of load balancer among ELBs. It is characterized by its wide range of protocol support, including TCP, SSL/TLS, HTTP, and HTTPS. It provides basic load balancing across multiple EC2 instances and operates at both the request and connection levels. It is intended for applications built within the EC2-Classic network. Its weakness is its inability to allow for complex configuration, and AWS no longer recommends its use. |
In addition to the three typical AWS ELBs mentioned above, there is also the GLB
GLB stands for Gateway Load Balancer
The Gateway Load Balancer makes it easy to deploy, scale, and run third-party virtual network appliances.
Providing load balancing and auto-scaling for fleets of third-party appliances, the Gateway Load Balancer is transparent to the source and destination of traffic.
This capability makes it ideal for working with third-party appliances for security, network analysis, and other use cases.
Reference site: Elastic Load Balancing
This service has only just been released, so I'd like to learn more about it and then write a separate blog post about it!
By the way, when I tested ALB to write this blog,
simply linking the ALB to the test instance returned a "403" status code when I checked the access log.
172.31.4.72 - - [15/Jun/2021:07:59:03 +0000] "GET / HTTP/1.1" 403 4897 "-" "ELB-HealthChecker/2.0"
In this case, place an "index.html" file under the document root, add the words "aws test" to the file, and access it from a browser. A "200" status code will be returned.
*This requires that Apache is installed on the server.
First, navigate 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 your browser, you can do so by entering the public IPv4 address in the Chrome search bar
Let's check the access log again!
172.31.4.72 - - [15/Jun/2021:08:38:35 +0000] "GET / HTTP/1.1" 200 9 "-" "ELB-HealthChecker/2.0"
The status code successfully became "200", and when I checked the "Target Group" in the AWS console, the status of the "Target Group" had also changed from "Unhealthy" to "healthy"!
summary
For example, a load balancer
"This is your job" "I'd like you to do this job"
He is like a boss (command center) in a company
By using a load balancer effectively, you can prevent server downtime and eliminate problems such as delayed site display or the site not displaying at all, which will likely increase the reliability of your site
I would also like to become someone who can do work like a load balancer
Growing every day, progressing every day.
I have to update myself every day!!!
Thank you for reading to the end.
6