Submitted by heartin on Sat, 12/23/2017 - 16:45
Problem:
Elastic Load Balancing supports two types of load balancers: Application Load Balancers (new) and Classic Load Balancers. Demo the use of both.
Solution Summary:
First we will create and demo classic load balancer and then we will create application load balancer.
Solution Steps:
- Login to AWS console and go to EC2 dashboard page.
- Start your EC2 instance which renders a page using the httpd service (refer to previous labs).
- Login through ssh and verify if httpd is running and the insex.html file is present (refer to previous labs).
- Click on ‘Load Balancers’ under ‘Load Balancing’ side tab.
- Click on Create Load Balancer. You should get options for creating two types of load balancers: Application Load Balancers (new) and Classic Load Balancers.
- Click on classic load balancer
- Give a name (e.g. BuddyClassicELB)
- Select My Default VPC.
- Leave other options unchecked (create an internal load balancer, enable advanced vpc configuration, Listener configuration). Verify that HTTP is available under Load Balancer Protocol.
- Click next and add it to BuddyWebDMZ security group ( created before with EC2).
- You may get an error message as you are not using HTTPS; you may ignore it. Click next.
- Configure Health Check. Leave Ping Protocol as HTTP, Ping Port as 80, Ping Path as /index.html, Response timeout as 2, Interval as 30 seconds, Unhealthy threshold as 2, Healthy threshold as 3. Read the info alongside all options to understand what they do. Click next.
- Add the EC2 instance. Click Next.
- Add tags to monitor charges in the account (e.g. BuddyProductionELB with value ON). Click next.
- Review and create. Click close on the success message and review the newly created ELB like the Health Check tab. You also need to wait until your EC2 status is ‘InService’.
- Copy the DNS and run it on browser to see your index.html page loaded.
- Simulate a failure by deleting or renaming the index.html file in the server through ssh. In few seconds, you should see your instance status as ‘outOfService’ in ELB dashboard. This can be a hack for taking an instance out of service, and once status is ‘outOfService’ ELB will not send any requests to it.
- Restore the index.html file and make sure EC2 status is ‘InService’.
- Click on Create Load Balancers.
- Select application load balancer.
- Give a name (e.g. BuddyApplicationELB). Leave scheme as Internet facing. Leave the HTTP listener as is. Use default VPC. Click Next
- Click next as we are using only HTTP.
- Add to our security group.
- Configure Routing: Select New Target Group, Give a name (e.g. BuddyAppELB), leave port as 80. For health check leave protocol as HTTP, path as /index.html. Leave port as traffic port. Leave thresholds, interval and and timeout as before. Leave status code as 200. Click next.
- Configure Target: Add our server by selecting and clicking ‘Add to Registered.’
- Review and create. Click close on the success message and review the newly created ELB like the Health Check tab. You also need to wait until your status is ‘active.
- Explore various options and metrics.
- Copy the DNS and run it on browser to see your index.html page loaded.
Comments
to verify if httpd is running
service httpd status