Tech Junkie Blog - Real World Tutorials, Happy Coding!: Iaas With AWS: Create A Classic Load Balancer

Wednesday, September 15, 2021

Iaas With AWS: Create A Classic Load Balancer

 In the previous post we went over what a load balancer is, in this post we are going to create one of types of load balancer AWS offers.  We are going to create a Classic Load Balancer, this balancer is not recommended by Amazon, you should only create this if you have to support EC2-Classic instances.

Before we create the load balancer we need to create more than one instances with a web server because we need to test that the load balancer is able to switch.

1. Create two instances with the user data to create Apache Web Servers with these commands in the User Data for instance, if you need the full instruction on how to create instances with User Data you can read this post

#cloud-boothook
#!/bin/bash
#Use this for your user data (script without newlines)
# install httpd (Linux 2 version)

yum update -y 
yum install -y httpd.x86_64 
systemctl start httpd.service 
systemctl enable httpd.service 
echo "Hello world from $(hostname -f)" > /var/www/html/index.html

We just created an index.html file to write out the hostname for testing later on


2. For the Security Groups setting make sure there's an inbound rule for HTTP traffic



3. On the create the two instances, if you copy and paste the public DNS or public IP into the address bar of the browser you see the hostname being printed out for the instance, so if the load balancer is successfully the request should change to a different host when a user requests the site
Now its time to create the Classic Load Balancer

4. On EC2 Dashboard scroll down to "LOAD BALANCING" and click on "Load Balancers",  then click on the "Create Load Balancer" button you will be presented with three choices.  The Classic Load Balancer is grayed out because AWS does not want you to choose it.  Choose the Classic Load Balancer by clicking on the "Create" button

5.  On the next page accept the default because Load Balancer accepts HTTP requests on port 80, so does our instance

6. On the Security Groups page, make sure that you have an inbound rule that accepts HTTP requests on port 80


7.  The next page is the Health Check page, it will check the health of the instances by pinging the page index.html on port 80, accept the default and click Next

8.  On Add EC2 Instances page you want to add the two instances that we've created with the User Data and accept the default, then click "Next" , click on "Review and Create" and then click on "Create"
Once the Load Balancer has been created you can copy and paste the Load Balancer's DNS into the browser's address bar and it would alternate between the two instances.  You will have to wait for a while for it to work, the instances will have a status of OutOfService while it is being added to the load balancer


Here is result you should get when everything is finished.


10 comments:

  1. Thank you for sharing your info. I really appreciate your efforts and I am waiting for your further write ups thank you once again. And know Mimz International Merchandising Company provides services to clients to Make their Vision a Reality and to help companies to improve business performance. merchandising

    ReplyDelete
  2. Thank you for sharing Detailed Information. Appreciate it!

    ReplyDelete
  3. Nice, I really Like Your Article Its look like You Spent a Lot of Time and Effort on Your Blog
    Thanks for Sharing With Us.

    PVR Anmol
    PVR Maha


    ReplyDelete
  4. Thanks for sharing this, very helpful. Need a logo for your business? Just look below:
    buy a logo

    ReplyDelete
  5. Nice Blog,I feel like all your ideas are incredible! Great job!!!
    I have some information about:

    Prestige High Fields
    Brigade Citadel
    Pbel City

    ReplyDelete
  6. Nice Blog... Thank you for sharing this information.

    Brigade Citadel

    2/3 BHK Flats for Sale in Hyderabad

    ReplyDelete
  7. Hi your blog really great and helpful for me. bellen amazone

    ReplyDelete
  8. Right-click the icon and choose “Add a Bluetooth Device” from the context menu. If you're using Windows 8 or 10, you'll see a screen like the one below. Just hit the “Pair” button for the device you want to connect

    the foundry mari crack

    ReplyDelete
  9. SMR Vinay Iconia is developed by SMR Holdings, Located in Kondapur, Hyderabad. It provides 2 & 3 bhk luxury flats available for sale in Affordable prices.
    SMR Vinay Iconia Structure:
    Location of the Project: Kondapur, Near Gachibowli
    Available Bedrooms: 2BHK, 3bhk & 4BHK
    Total Land area: 22 Acres
    Total units : 2550
    Total Towers: 11 towers
    Total Floors: G+35 floors

    ReplyDelete

Search This Blog