4.11 Elastic Load Balancer & Health Check - Lab
Elastic Load Balancer can play a role as a load balancer of your EC2 instances, it can also be used to check the health of your EC2 instances.
Steps:
Start your EC2 instance and SSH into the instance as root user.
Check the Apache web server is running or not using "service httpd status", if not, using "service httpd start" to start your server. Using "chkconfig httpd on" to guarantee your httpd service will be on automatically every time you reboot your instance.
Go to /var/www/html directory and edit/create index.html file.
In the console dashboard, go to Load Balancer, and Create Load Balancer. There are two kinds of load balancers:
Application Load Balancer: it works at layer 7, the application layer (HTTP, HTTPS).
Classical Load Balancer: it works at layer 4, the transport layer (TCP). It can also do some layer 7 routing.
We choose the Classical Load Balancer (Application Load Balancer is relatively new, there will not be questions about it in the exam).
You need to configure the Load Balancer Protocol and the Instance Protocol, because they are two different services and you need to make them communicate with each other.
When you get to the step of Configure Health Check, you need to provide a html file path to Ping Path, this file will be used to check the health of the EC2 instance. If the ELB cannot find the file throught the Ping Path, ELB will display that the instance is OutOfService. This is a good property of ELB, because if one of your instance is not working or not accessible, ELB will not send traffic to this instance. ELB will send traffic to other healthy instances and guarantee that there will not be any downtime to users. There are also some other advanced configuration you can configure.
Now you can Add EC2 Instances to this Load Balancer. Then You can visit the index.html file which is stored in your EC2 instance through the DNS name of your ELB, because the DNS resolution provided by Amazon will convert the DNS name of our ELB to the public IP address of the ELB, and ELB will redirect you to one of our EC2 instance. You should notice that what you get is the public IP address of the EC2 instance, but not the public IP address of your ELB. Amazon manages the public IP address of the ELB for you, so you cannot see the public IP address of the ELB, you can only see the DNS name of it. The reason is that the public IP address of ELB can change.
ELB will cost your money if you leave them on, so adding tags is important. Key can be the name of the ELB, and value can be the on/off status of the ELB.
For the Applicaiton Load Balancer, you can create ELB across multiple AZ, and you need to remember that one Subnet equals to one AZ. Through registering targets to add EC2 instances to your ELB.
Summary:
ELB is designed to only run in single Region, but can run in multi-AZs for HA.
ELB can route traffic across multiple instances and multiple AZs.
By default, Classic Load Balancer distributes incoming traffic evenly across its enabled AZs. Enable Cross-Zone Load Balancing can help you to ensure the traffic is evenly distributed across multiple AZs. By default, Cross-Zone Load Balancing is enabled. When it is disabled, there might be only one AZ's instances can receive traffic.
ELB ensures that only healthy instances receive traffic by health-checking and will not route traffic to unhealthy instance. This achieves fault tolerance for your application.
Instances monitored by ELB are reported as InService or OutOfService.
Health Checks check the instance health by simply talking to it through HTTP or HTTPS. You can use individual html file to be used to health check, for example healthcheck.html, but more people just use the landing page of the website, for example index.html.
ELB have their own DNS name. You are never given an IP address to an ELB. Amazon handle the DNS resolution to you all on their own. We will learn how we can use the ELB in conjunction with Route53 in order to configure a domain name to point to your ELB, and then point to your EC2 instance.
When you add an AZ to your ELB, ELB creates a load balancer node in the AZ. Load balancer nodes accept traffic from clients and forward requests to the healthy registered instances in one or more AZs.
Please read the ELB FAQ for Classical Load Balancer in order to prepare the exam.
Last updated
Was this helpful?