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,
- 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.
- In the Health checks section, modify the default settings as needed
Advanced health check settings:
- Choose the health check port
- specify success codes
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.
- Choose Add tag.
- Enter the tag** Key** and tag Value
- Choose Next
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
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
- 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.
To configure your load balancerTake the following stapes:
- On the navigation pane, under LOAD BALANCING, choose Load Balancers.
- Choose Create Load Balancer.
- Chose the type of the Load Balancer. For application Load Balancer, choose Create
- For Load balancer name, enter a name for your load balancer.
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
- 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.
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.
5. For Mappings**, select two or more Availability Zones and corresponding subnets. Enabling multiple Availability Zones increases the fault tolerance of your applications.
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
• 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).
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.
- 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.
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.
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.
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
- After the load balancer is created, choose Close.
- In the navigation pane, under Load Balancing, choose Target Groups.
- Select the newly created target group.
- 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,
- In the navigation pane, under Load Balancing, choose Load Balancers.
- Select the newly created load balancer.
- 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.