A Network Load Balancer (NLB) is a component used in computer networking to distribute incoming network traffic across multiple servers or resources, ensuring that the workload is evenly distributed. It plays a crucial role in improving the availability, scalability, and reliability of network-based services.
There are generally two types of Network Load Balancers:
Layer 4 Load Balancer: Also known as a transport-layer load balancer, this type of NLB operates at the transport layer (Layer 4) of the OSI model. It primarily focuses on distributing traffic based on network-level information such as IP addresses and port numbers. Layer 4 load balancers are typically fast and efficient but lack visibility into application-level details.
Layer 7 Load Balancer: Also called an application-layer load balancer, this type of NLB operates at the application layer (Layer 7) of the OSI model. It can make more intelligent load balancing decisions by inspecting the content of the network traffic, including HTTP headers, cookies, and other application-specific data. Layer 7 load balancers offer advanced features like SSL/TLS termination, content-based routing, and session persistence.
The functions of a Network Load Balancer
Traffic Distribution: The primary function of an NLB is to evenly distribute incoming network traffic across multiple servers or resources. This distribution can be based on various algorithms such as round-robin, least connections, IP hash, or weighted distribution. By distributing the traffic, NLBs ensure that no single server becomes overwhelmed, optimizing resource utilization.
High Availability: NLBs play a crucial role in achieving high availability for network-based services. By distributing traffic across multiple servers, NLBs help eliminate single points of failure. If one server fails or becomes unresponsive, the NLB redirects traffic to other healthy servers, ensuring that the service remains available to users.
Scalability: NLBs enable horizontal scalability by allowing new servers or resources to be added to the load balancer pool seamlessly. As the demand for the service grows, additional servers can be provisioned and added to the pool, and the NLB automatically distributes the traffic to the new resources. This scalability ensures that the service can handle increased traffic without any degradation in performance.
Health Monitoring: NLBs continuously monitor the health of the servers or resources in the pool. They periodically send health checks to ensure that the servers are responsive and capable of handling traffic. If a server fails the health check, the NLB automatically removes it from the pool and stops sending traffic to it until it becomes healthy again. This feature helps maintain the overall health and reliability of the system.
SSL/TLS Termination: Layer 7 NLBs often provide SSL/TLS termination, allowing them to offload the computationally intensive task of decrypting and encrypting SSL/TLS traffic from the backend servers. This offloading reduces the processing burden on the servers and improves their overall performance.
Content-based Routing: Layer 7 NLBs can inspect the content of the network traffic and make load balancing decisions based on application-specific data. This capability enables advanced routing scenarios, such as directing traffic to specific servers based on URL paths, HTTP headers, or cookies. Content-based routing helps optimize the distribution of traffic based on the specific needs of the application.