Implementing a load balancer

The load balancer distributes network traffic across the servers to improve use concurrency, reliability, and application latency. The load balancer can be physical or virtual. You need to choose a load balancer based on your application's need. Commonly, two types of load balancer can be utilized by the application:

  1. Layer 4 or network load balancer: Layer 4 load balancing routes packets based on information in the packet header—for example, source/destination IP addresses and ports. Layer 4 load balancing does not inspect the contents of a packet, which makes it less compute intensive and therefore faster. A network load balancer can handle millions of requests per second.
  2. Layer 7 or application load balancer: Layer 7 load balancing inspects, and routes packets based on the full contents of the packet. Layer 7 is used in conjunction with HTTP requests. The materials that inform routing decisions are factors such as HTTP headers, URI path, and content type. This allows for more robust routing rules but requires more compute time to route packets. The application load balancer can route the request to containers in your cluster based on their distinctive port number.

Depending on the environment, you can choose hardware-based load balancers, such as an F5 load balancer or a Cisco load balancer. You can also choose a software-based load balancer, such as Nginx. The public cloud provider AWS facilitates a managed virtual load balancer called Amazon Elastic load balancer (ELB). ELB can be applied at layer 7 as an application load balancer and tier 4 as a network load balancer.

A load balancer is a great way of securing your application, making it highly available by sending a request to healthy instances. It works together with autoscaling to add or remove instances as required. Let's look at autoscaling and learn how it helps to improve overall performance and the high availability of your application.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.1.158