How to choose Load Balancer ( AWS and GCP )

Subhajit Dutta
3 min readJun 6, 2021

--

Stolen from Google Image

Introduction ( TL;DR )

If you are familiar with Google Cloud Platform or AWS, you must be aware of famous software-based load balancers, all they do is, efficient distribution of network or application traffic across multiple servers. They usually sit in between client devices and backend servers.

Now there are several options for selecting a Load Balancer from popular Cloud Providers. Today, let's discuss the differences between a Load Balancer based on layers of the OSI Model: Layer 4 and Layer 7.

Enough intro…

Layer 4 Load Balancer

Layer 4 is nothing but the Transport Layer of the OSI Model. This is Network Load Balancer in AWS and TCP/UDP Load Balancer in GCP.

Layer 4 load balancers usually route traffic based on IPs, TCP, or UDP ports, do not care about the content of the message, and deals with the delivery of the packets. The load balancer delivers traffic by combining this limited network information with a load balancing algorithm such as round-robin and by calculating the best destination server based on the least connections or server response times.

Benefits

  1. Control routing rules based on IP or TCP/UDP packets
  2. A simple approach for Packet-Level load balancing
  3. Messages are neither inspected nor decrypted, allows them to deliver messages quickly, efficiently, and securely.
  4. Preservers client source IP

Drawbacks

  1. Not possible to route traffic based on media-type, localization rules.
  2. It is fast but can’t perform any action on the protocol above layer 4.
  3. Cannot access features of Application Layer, eg. routing based on the path

Layer 7 Load Balancer

These load balancers work on top of the application layer of the OSI model. AWS calls them Application Load Balancer and in GCP, these are HTTP(s) load balancer.

Dealing with the actual content of each message, HTTP is the predominant Layer 7 protocol for website traffic on the Internet. Layer 7 load balancers route network traffic in a much more sophisticated way than Layer 4 load balancers, particularly applicable to TCP‑based traffic such as HTTP.

While the need for encryption incurs a performance penalty for layer 7 processing, this can be largely reduced through the use of SSL offload functionality.

Layer 7 Load Balancer supports a unique feature called Session Affinity or Sticky Session which can identify unique client sessions to provide server persistence, sending all client requests to the same server for greater efficiency.

A device that performs Layer 7 load balancing is often referred to as a reverse‑proxy server.

Benefits

  1. Control routing rules based on IPs, TCP or UDP ports, or any information it can get from the application protocol (mainly HTTP)
  2. It is capable of performing optimizations and changes to the content (such as compression and encryption)
  3. Session Affinity or Sticky Sessions for identifying servers
  4. SSL/TLS offloading

Drawbacks

  1. More CPU‑intensive than packet‑based Layer 4 load balancing.
  2. Little slower than Layer 4 LB because of the complex underlying algorithm.

Decision Tree ( GCP )

Resources

  1. https://en.wikipedia.org/wiki/OSI_model
  2. https://cloud.google.com/load-balancing/docs/network
  3. https://cloud.google.com/load-balancing/docs/https
  4. https://aws.amazon.com/elasticloadbalancing/application-load-balancer/
  5. https://aws.amazon.com/elasticloadbalancing/network-load-balancer/
  6. https://aboutssl.org/what-is-ssl-offloading/
  7. https://www.nginx.com/resources/glossary/reverse-proxy-server/

--

--