What is LoadBalancer and Creating Load Balancer-Awsbloginfo

Load Balancer is a virtual machine or appliance that balances your web application load that could be Http or Https traffic that you are getting in. It balances a load of multiple web servers so that no web server gets overwhelmed.

AWS Load Balancing

Application Load Balancer

AWS Load Balancing
  • An Amazon Web Services (AWS) launched a new load balancer known as an Application load balancer (ALB) on August 11, 2016.
  • It is used to direct user traffic to the public AWS cloud.
  • It identifies the incoming traffic and forwards it to the right resources. For example, if a URL has /API extensions, then it is routed to the appropriate application resources.
  • It is operated at Layer 7 of the OSI Model.
  • It is best suited for load balancing of HTTP and HTTPs traffic.
  • Application load balancers are intelligent, sending specific requests to specific web servers.
  • If we take an example of TESLA. We have three models of TESLA, i.e., TESLA Model X, TESLA Model S, and TESLA Model 3 and TESLAs have onboard computing facility. You will have a group of web servers that serve the Model X, a group of web servers that serve the Model S, and similarly for Model 3. We have one Load balance that checks whether the incoming traffic comes from either Model X, Model S or Model 3, and then sends it to the intended froup of servers.

Network Load Balancer

AWS Load Balancing
  • It is operated at the Layer 4 of the OSI model.
  • It makes routing decisions at the transport layer (TCP/SSL), and it can handle millions of requests per second.
  • When a load balancer receives a connection, it then selects a target from the target group by using a flow hash routing algorithm. It opens the TCP connection to the selected target of the port and forwards the request without modifying the headers.
  • It is best suited for load balancing the TCP traffic when high performance is required.

Classic Load Balancer

AWS Load Balancing
  • It is operated at Layer 4 of the OSI model.
  • It routes the traffic between clients and backend servers based on IP address.
  • For example, an Elastic Load balancer receives a request from a client on TCP port 80, it will then routes the request to a specified port of backend servers. The port on which the Load Balancer routes to the target server will be having port number 80. The backend server will then send the requested data back to the ELB, which will then forward the Backend server reply to the client. According to the client's perspective, the request has been fulfilled by the ELB, not by the backend server.
  • Classic Load balancers are legacy Elastic load balancers.
  • It can also be used for load balancing the HTTP or HTTPs traffic and use layer 7-specific features, such as X-forwarded and sticky sessions.
  • You can also use the Layer 4 load balancing for applications that rely purely on the TCP protocol.

Load Balancer Errors

  • Classic Load Balancer

If you get an error 504, this is a gateway timeout error. A Load balancer is still available, but it has a problem in communicating with the EC2 instance. If your application stops responding, the ELB (Classic Load Balancer) responds with a 504 error. This means that the application is having issues and it could be either at the web server layer or the Database layer.

In order to troubleshoot where the application is failing, and scale it up or out where possible.

X-Forwarded-For-Header

The X-Forwarded-For-Header is used to determine the IP address of a client when you use a classic load balancer.

Working of X-Forwarded-For-Header

AWS Load Balancing
  • A user is on the Ipv4 address, i.e., 124.12.3.23.
  • A user is sending a request to the classic load balancer which in turn folded the request into an EC2 instance. An EC2 instance is going to use the private address, i.e., 10.0.0.23 and this is the only address which is seen by an EC2 instance.
  • An EC2 instance is capturing only private address as Classis Load balancer encompasses the Public IP address. The public address is needed as it provides valuable information such as "who are using your website".
  • An EC2 instance gets the Ipv4 address in the form of X-Forwarded-For request Header from the Classic load balancer.

Creating a Load Balancer

  • Sign in to the AWS Management Console.
  • Create an EC2 instance.
  • An EC2 instance is in a stopped state. Start the instance by clicking on the Actions dropdown menu and then click on the start.
Creating Load Balancer

Now, my instance is running, and its IP address is 18.191.224.149.

  • Open the putty.
  • Run the command sudo su to provide the privileges to the root device.
  • Run the command yum update ?y to update the EC2 instance.
  • Install the Apache server by using the command yum install httpd ?y.
Creating Load Balancer

The above screen shows that the server has been installed successfully.

  • Start the server by using the command service httpd start.
Creating Load Balancer

  • Move to the html directory by running the command cd /var/www/html.
  • Run the command nano index.html to create the editor.
Creating Load Balancer

  • Now, we are going to create nano healthcheck.html file.
Creating Load Balancer

  • I write "My instance is running" to healthcheck file.
Creating Load Balancer

  • Move to the EC2 service, click on the Load Balancer appearing on the left side of the console.
  • Click on the Create Load Balancer. On clicking, three types of Load Balancers are shown:
Creating Load Balancer

  • We create a Classic Load Balancer.
  • On clicking on the create button, the screen appears shown below:
Creating Load Balancer

Creating Load Balancer

Load Balancer name: It is the name of the Load balancer that the user provides. Suppose I have given a ClassicELB as a load balancer name.

Create LB inside: I kept it as a default VPC.

Create an internal load balancer: As we want to serve external web traffic, so we need an external load balancer, not an internal load balancer. Uncheck this field.

Enable advanced VPC configuration: Check this field to add at least one subnet.

Linear Configuration: It describes from which protocol and port, it is listening, and to which port it is passing.

  • Click on the Next button.
  • Configure Health check.
Creating Load Balancer

Ping Protocol: It defines the type of protocol.

Ping port: It defines the port number.

Ping Path: It defines the path of the web page that we created, i.e., healthcheck.html.

Response Timeout: It defines how long it will take and waits for the response.

Interval: It is the amount of time between health checks.

Unhealthy threshold: It defines the number of consecutive health check failures before declaring an EC2 instance unhealthy.

Healthy threshold: It defines the number of consecutive health check successes before declaring an EC2 instance healthy.

  • Click on the Next.
  • Add your EC2 instance to the Load Balancer. Check the EC2 instance box.
Creating Load Balancer

  • Click on the Next.
  • Review the load balancer, and then click on the Create button.
Creating Load Balancer

Creating Load Balancer

The above screen shows that Class load balancer has been successfully created.

  • When we check the status of an instance, the status appears as OutOfService.
Creating Load Balancer

  • After 1 or 2 minutes, the status of an instance appears as InService.
Creating Load Balancer

  • Copy the DNS name of a Load balancer and paste it to the clipboard of a web browser. You will see the output which is shown below:
Creating Load Balancer

Therefore, we can say that DNS name is converted into a public IP address which is directing you to the index.html. Amazon provides DNS name to the Classic Load Balancer rather than a public IP address as the public IP address can be changed.

Note: Once the EC2 instance is out of service, the load balancer would not send the traffic to EC2 instance as it is presuming that healthcheck file that we created has been failed.

Comments

Popular posts from this blog

Relational Database-Awsbloginfo

AWS Blog Info - Content

Introduction To Amazon Web services-AWS Blog Info