Sunday, March 20, 2022

AWS Compute - ELB (Elastic Load Balancing)


Elastic Load Balancing

Elastic Load Balancing automatically distributes your incoming traffic across multiple targets, such as EC2 instances, containers, and IP addresses, in one or more Availability Zones.

It monitors the health of its registered targets and routes traffic only to the healthy targets.


Classic Load Balancer

1. Create 2 EC2 instances with User Data to install httpd.

    In the User Data, put in this script:

#!/bin/bash

sudo yum update -y

sudo yum install -y httpd

sudo systemctl start httpd

sudo systemctl enable httpd

2. Connect to first EC2 instance and run below commands

     echo "<h1>Server 1 </h1>" >> /var/www/html/index.html

3. Connect to second Ec2 instance and run below command

   echo "<h1>Server 2 </h1>" >> /var/www/html/index.html

4. Go to Load Balancing and Select Load Balancers

5. Click on Create Load Balancer and Select Classic Load Balancer and Click on Create button.

6. Define LoadBalancer Properties.

  • Load Balancer Name:  CLB
  • The rest of the properties leave as it is, I am creating in the default VPC and Load Balancer Protocol is HTTP because in my EC2 instances the service is running on Port 80 with HTTP protocol.
  • Click on Next button

7. Select the security Group :- Webserver (Any SG which has port 80 opened) and click on Next

8. No Change on this page, you may see a warning that the application is using insecure protocol HTTP click Next button.

9. Configure Health Check for EC2 instances and Click on Next button

10. Add EC2 instances and Add both EC2 instances and click on Next Button

11. Tags No Change and Review and Create .

12. Once CLB is created then it will have it defined properties, You can access the CLB using its DNS.

13 Use DNS Name on browser and check it will be connected to server1 and server2 frequently.


No comments:

Post a Comment

Fluentd

Open-source log data collector > why logs? - for compliance (auditing, company, business) - for security (transparency, monitoring, admin...