What is Load Balancing?
Load balancing is the method of distributing network traffic equally across a pool of resources that support an application. Modern applications must process millions of users simultaneously and return the correct text, videos, images, and other data to each user in a fast and reliable manner. To handle such high volumes of traffic, most applications have many resource servers with duplicate data between them. A load balancer is a device that sits between the user and the server group and acts as an invisible facilitator, ensuring that all resource servers are used equally.
Benefits of load balancing:
Load balancing directs and controls internet traffic between the application servers and their visitors or clients. As a result, it improves an application’s availability, scalability, security, and performance.
Application availability:
Server failure or maintenance can increase application downtime, making your application unavailable to visitors. Load balancers increase the fault tolerance of your systems by automatically detecting server problems and redirecting client traffic to available servers. You can use load balancing to make these tasks easier:
Run application server maintenance or upgrades without application downtime
Provide automatic disaster recovery to backup sites
Perform health checks and prevent issues that can cause downtime
Application scalability:
You can use load balancers to direct network traffic intelligently among multiple servers. Your applications can handle thousands of client requests because load balancing does the following:
Prevents traffic bottlenecks at any one server
Predicts application traffic so that you can add or remove different servers, if needed
Adds redundancy to your system so that you can scale with confidence
Application security:
Load balancers come with built-in security features to add another layer of security to your internet applications. They are a useful tool to deal with distributed denial of service attacks, in which attackers flood an application server with millions of concurrent requests that cause server failure. Load balancers can also do the following:
Monitor traffic and block malicious content
Automatically redirect attack traffic to multiple backend servers to minimize impact
Route traffic through a group of network firewalls for additional security
Application performance:
Load balancers improve application performance by increasing response time and reducing network latency. They perform several critical tasks such as the following:
Distribute the load evenly between servers to improve application performance
Redirect client requests to a geographically closer server to reduce latency
Ensure the reliability and performance of physical and virtual computing resources.
Basically load Balancer will act like work done by a manager in a restaurant. Consider a restaurant with five waiters. If customers were allowed to choose their waiters, one or two waiters could be overloaded with work while the others are idle. To avoid this scenario, the restaurant manager assigns customers to the specific waiters who are best suited to serve them.
Types of Load Balancer:
1.Application Load Balancer (ALB) - operates at layer 7 of the OSI model and is ideal for applications that require advanced routing and microservices
2.Network Load Balancer (NLB) - operates at layer 4 of the OSI model and is ideal for applications that require high throughput and low latency.
3.Classic Load Balancer (CLB) - operates at layer 4 of the OSI model and is ideal for applications that require basic load balancing features.
Elastic Load Balancing supports the following types of load balancers:
Application Load Balancers, and Network Load Balancers.
Application Load Balancers are used to route HTTP/HTTPS (or Layer 7) traffic.
Network Load Balancers and Classic Load Balancers are used to route TCP (or Layer 4) traffic.\
OSI MODEL:
Application Load Balancer components include:
Load balancer. The load balancer distributes incoming application traffic across multiple targets (e.g., EC2 instances in multiple AWS availability zones) to increase application availability.
Listener. A listener checks for connection requests from clients using the protocol and port configured by an organization per rules that determine how Application Load Balancer routes requests to registered targets.
Target group. Application Load Balancer routes requests to one or more registered targets (e.g., EC2 instances) using the protocol and port number configured by an organization.
When Application Load Balancer receives requests, it evaluates the listener rules to determine which rule to apply. Next, it selects a target from the target group for the selected rule's action. Routing is performed independently for each target group.
The default routing algorithm is round robin. However, users can also specify the least outstanding requests routing algorithm.
Targets can be added to or removed from the Application Load Balancer as needs change without disrupting the flow of requests to the application.
Task 1:
launch 2 EC2 instances with an Ubuntu AMI and use User Data to install the Apache Web Server.
Modify the index.html file to include your name so that when your Apache server is hosted, it will display your name also do it for 2nd instance which include " TrainWithShubham Community is Super Aweasome :) ".
Copy the public IP address of your EC2 instances.
Open a web browser and paste the public IP address into the address bar.
You should see a webpage displaying information about your PHP installation.
Server1:
Server:2
Task 2:
Create an Application Load Balancer (ALB) in EC2 using the AWS Management Console.
Add EC2 instances which you launch in task-1 to the ALB as target groups.
Verify that the ALB is working properly by checking the health status of the target instances and testing the load balancing capabilities.
Create Load Balancer:
Try to access DNS:mylbec2-296742893.us-east-1.elb.amazonaws.com
Here you go!
Thank you for reading!! Hope you find this helpful.
#day41#90daysofdevops#devopscommunity#trainwithshubham
Always open for suggestions..!!