How to Create Load Balancer
Tags: awscommunitybuilder, aws, usergroup, iug
Published: 2022-09-26 19:36:54


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yot2zb9aux149i5v1eny.png)




- 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/of9uclru476rtqfi7byo.png)


- In the **Health checks** section, modify the default settings as needed


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/453s5f01i8xo7fq1xb4c.png)


**Advanced health check settings:**

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/227xqamzpy6c07k61fks.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/do8fra322o61lgp0rvle.png)



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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ob2fmfzhgmbqo3jttjot.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vfrqipecfkins5zllcc7.png)



**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.

4. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/omlvmqv75hhj93izv7wm.png)

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pi2wwclkbaiy42mo6bpr.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgkr001cwot7ylv5tuj4.png)

**Basic configuration:**

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bn8fu61pev5qdasge8rk.png)

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.
3. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1jjcpx557zjwpw7bsiij.png)


**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yk9x0nacg5ut7jrgk4vj.png)

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hr7wlellg1416avu13ca.png)


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/et3ochi7izcp4lndu9g0.png)

•  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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jytr33alk9ci521onvgl.png)

**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hh5w69kzjcsdbc3p6eju.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/362ya5b3soc54yy6ka9o.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f4x5o0w18983k7wxi935.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yrkt1ksvw5svn1lugax8.png)
The load balancer is create, and when select you can see the description of load balancer and other feature .



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9r7zueu93k2mrsopa1nc.png)



**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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j0knckmscpzj7z9l057w.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vw541zst8aiq41w7cve3.png)



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2b2h66p7k3hbqxx0lv4g.png)


9. In the navigation pane, under **Load Balancing**, choose **Load
Balancers**.
10. Select the newly created load balancer.
11. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ws9r1izumlsbxgo9tio8.png)