In the previous post we went over how to create a Network Load Balancer, in this post we are going to create one of types of load balancer AWS offers. We are going to create a Application Load Balancer, this balancer is designed to work best with the typical line of business web applications. It deals mostly with the requests/response scenarios on the web, therefore it supports the HTTP, and HTTPS protocols exclusively. It can be setup to respond to the routes that configured or the hosts. It all depends on how your web applications serves the client. In a way it's the easiest load balancer type to understand because it deals with headers, URLs, routes, parameters, query strings and etc.
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 four 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
cd /var/www/html/
cp index.html contacts.html
We just created an index.html file to write out the hostname for testing later on, we also created a new file called contacts.html so that we can have different routes.
To create more than one instance at a time, type in the number of instances in the "Number of Instances" field. Select no preferences for the subnets