Let's have a look at how to create a load balancer, and see the configuration details for an existing load balancer.
A. Prerequisite
Go to the EC2 dashboard. In order to use elastic load balancing, you will need to make sure that you've launched the EC2 instances that you plan to register with your load balancer.
You must have more than one EC2 instance in the running state. In our example snapshot below, we have two instances, in two different availability zones (AZs).
Snapshot: Two servers, in different AZs, hosting the same application.
B. Start the Load Balancer service
On the EC2 dashboard, select the Load Balancers service from the navigation pane on left. Here, you can view the list and details of existing load balancers.
Snapshot: Load Balancers
Launch the Create Load Balancer wizard. AWS offers three types of load balancers, as shown below.
Snapshot: Three types of load balancers.
-
Application Load Balancer (ALB)
A simple use case: Assume you are running a microservices-architecture based application. An Application Load Balancer allows you to host the different API endpoints of your application on different servers. The load balancer then redirects the incoming HTTP/HTTP traffic to the suitable server based on the rules you specify in the configuration.If you choose this option, you will be taken to a six-step process:
- Configure Load Balancer
- Configure Security Settings
- Configure Security Groups
- Configure Routing
- Register Targets
- Review
-
Network Load Balancer (NLB)
A Network Load Balancer helps to balance the load on each individual server. Having an NLB becomes essential when your application requires handling millions of requests per second securely while maintaining ultra-low latencies.This option has a five-step process:
- Configure Load Balancer
- Configure Security Settings
- Configure Routing
- Register Targets
- Review
See an example NLB below:
Snapshot: An NLB balancing the load within a Target Group of instances
-
Classic Load Balancer (CLB)
It is a previous generation option. You can choose a Classic Load Balancer when you have an existing application running in the EC2-Classic network. You will have to follow a seven-step process to create a CLB:- Define Load Balancer
- Assign Security Groups
- Configure Security Settings
- Configure Health Check
- Add EC2 Instances
- Add Tags
- Review
See an example CLB below:
Snapshot: A classic load balancer
The CLB in the snapshot above is balancing the load between two of our EC2 instances: Server_1
and Server_2
. If you click on the Instances tab, you're able to see the two instances that this load balancer is managing. You have the option to add or remove instances simply by clicking on Edit instances.
(Optional) External Resources
- Getting started with Application Load Balancers
- Getting started with Network Load Balancers
- Tutorial: Create a Classic Load Balancer