DEV Community

Zahraa Jawad
Zahraa Jawad

Posted on

How to Create Load Balancer

To create the load balancer complete the following tasks:

Step 1: Configure a target group
Step 2: Register targets
Step 3: Configure load balancer and a listener
Step 4: Test load balancer

Step 1: Configure a target group

Configuring a target group allows you to register targets such as EC2 instances.

To configure your target group:

Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the left navigation pane, under Load Balancing, choose Target Groups.
Choose Create target group.

In the Basic configuration section, set the following parameters:
For Choose a target type:
• select Instance to specify targets by instance ID
IP addresses to specify targets by IP address
• If the target type is a Lambda function,

Image description

  • For Target group name, enter a name for the target group.
  • Modify the Port and Protocol as needed.
  • For VPC, select a virtual private cloud (VPC) with the targets that you want to include in your target group.
  • For Protocol version, select HTTP1 when the request protocol is HTTP/1.1 or HTTP/2; select HTTP2, when the request protocol is HTTP/2 or gRPC; and select gRPC, when the request protocol is gRPC.

Image description

  • In the Health checks section, modify the default settings as needed

Image description

Advanced health check settings:

  1. Choose the health check port
  2. Timeout
  3. Interval
  4. specify success codes

Image description

If health checks consecutively exceed the Unhealthy threshold count, the load balancer takes the target out of service. If health checks consecutively exceed the Healthy threshold count, the load balancer puts the target back in service

Tags: (Optional chose)

To add one or more tags as follows Expand the Tags section.

  1. Choose Add tag.
  2. Enter the tag** Key** and tag Value
  3. Choose Next

Image description

Note: Allowed characters are letters, spaces, numbers (in UTF-8), and the following special
characters: + - = . _ : / @. Do not use leading or trailing spaces. Tag values are case-sensitive.

Step 2: Register targets

• Select one or more instances, enter one or more ports, and then choose Include as pending below.
• Then choose Create target group

Image description

Image description

Step 3: Configure a load balancer and a listener

To create an Application Load Balancer, you must first provide basic configuration information for your load balancer,
such as a name, scheme, and IP address type. Then, you provide information about your network, and one or more listeners. A listener is a process that checks for connection requests. It is configured with a protocol and a port for connections from clients to the load balancer.

How Application Load Balancers work:

1.Your client makes a request to your application.

2.The listeners in your load balancer receive requests matching
the protocol and port that you configure.

3.The receiving listener evaluates the incoming request against
the rules you specify, and if applicable, routes the request to
the appropriate target group. You can use an HTTPS listener to
offload the work of TLS encryption and decryption to your load
balancer.

  1. Healthy targets in one or more target groups receive traffic based on the load balancing algorithm, and the routing rules you specify in the listener.

Image description

To configure your load balancerTake the following stapes:

  1. On the navigation pane, under LOAD BALANCING, choose Load Balancers.
  2. Choose Create Load Balancer.

Image description

  1. Chose the type of the Load Balancer. For application Load Balancer, choose Create

Image description

Basic configuration:

  1. For Load balancer name, enter a name for your load balancer.

Image description

Note: The name of Application Load Balancer must be unique within your set of Application Load Balancers and
Network Load Balancers for the Region. Names can have a maximum of 32 characters, and can contain only alphanumeric characters and hyphens.

2. For Scheme:
choose Internet-facing or Internal. An internet-facing load balancer routes requests from clients to
targets over the internet. An internal load balancer routes requests to targets using private IP
addresses.

  1. For IP address type, choose IPv4 or Dualstack. Use IPv4 if your clients use IPv4 addresses to communicate with the load balancer. Choose Dualstack if your clients use both IPv4 and IPv6 addresses to communicate with the load balancer.

Image description

Network mapping:
4. For VPC, select the VPC that you used for your EC2 instances. If you selected Internet-facing for Scheme, only VPCs with an internet gateway are available for selection.

Image description

5. For Mappings**, select two or more Availability Zones and corresponding subnets. Enabling multiple Availability Zones increases the fault tolerance of your applications.

Image description

The security group for your load balancer must allow it to communicate with registered targets on both the listener port and the health check port. The console can create a security group for your load balancer on your behalf with rules that allow this communication. You can also create a security group and select it instead.

7. Listeners and routing

Image description

• For Default action, choose the target group that you created and can optionally choose Add listener to add another listener (for example, an HTTPS listener).

Image description

Add-on services (Optional)
Add-on services is use to add service, such as the AWS Global Accelerator that to create an accelerator and associate the load balancer with the accelerator.

Image description

Note:

  • The accelerator name can have up to 64 characters. Allowed characters are a-z, A-Z, 0- 9, . and - (hyphen).
  • Once the accelerator is created, you can use the AWS Global Accelerator console to manage it.

Tag (Optional)

Add a tag to categorize your load balancer. Tag keys must be unique for each load balancer.
Allowed characters are letters, spaces, numbers (in UTF-8), and the following special characters:

  • - = . _ : / @. Do not use leading or trailing spaces. Tag values are case-sensitive.

Image description

Review your configuration, and choose Create load balancer. A few default attributes are applied to your load balancer during creation. You can view and edit them after creating the load balancer.

Image description

Image description
The load balancer is create, and when select you can see the description of load balancer and other feature .

Image description

Step 4: Test the load balancer

After creating your load balancer, you can verify that your EC2 instances pass the initial health check.
You can then check that the load balancer is sending traffic to your EC2 instance.

To test the load balancer

  1. After the load balancer is created, choose Close.
  2. In the navigation pane, under Load Balancing, choose Target Groups.
  3. Select the newly created target group.
  4. Choose Targets and verify that your instances are ready. If the status of an instance is initial, it's typically because the instance is still in the process of being registered. This status can also indicate that the instance has not passed the minimum number of health checks to be considered healthy. After the status of at least one instance is healthy, you can test your load balancer. For more information,

Image description

Image description

Image description

  1. In the navigation pane, under Load Balancing, choose Load Balancers.
  2. Select the newly created load balancer.
  3. Choose Description and copy the DNS name of the load balancer (for example, my-load-balancer 1234567890abcdef.elb.useast-2.amazonaws.com). Paste the DNS name into the address field of an internet-connected web browser. If everything is working, the browser displays the default page of your server.

Image description

Top comments (0)