DEV Community

Cover image for Load Balancer in System Design – Part 2: Types of Load Balancers
ZeeshanAli-0704
ZeeshanAli-0704

Posted on

Load Balancer in System Design – Part 2: Types of Load Balancers

Load Balancing Series – Part 2: Types of Load Balancers

Table of Contents

  1. Introduction
  2. Based on OSI Layers
  3. Based on Deployment
  4. Comparing the Types
  5. Best Practices in Choosing a Load Balancer
  6. Conclusion

Introduction

In Part 1: Fundamentals of Load Balancing we discussed what load balancing is, why it’s essential, and how it improves system availability, scalability, and fault tolerance.

Now, let’s dive deeper into the types of load balancers, their characteristics, and when to use each.

Load balancers can be categorized based on how they operate (layers of the OSI model) and where they’re deployed (hardware, software, cloud, or DNS level).


Based on OSI Layers

Layer 4 Load Balancer (Transport Layer)

  • Operates at the TCP/UDP level.
  • Makes routing decisions based on IP address and port numbers (not application content).
  • Faster, lightweight, but lacks application awareness.

Example Use Case:

  • Gaming servers, chat apps, VoIP – where latency matters more than deep content inspection.

SQL Analogy: Like using an index only on primary keys – it’s fast but not content-aware.

Diagram Reference:

  • Imagine a traffic cop that only looks at the license plate (IP/Port), not what’s inside the vehicle (content).

Layer 7 Load Balancer (Application Layer)

  • Operates at the HTTP/HTTPS level.
  • Can inspect request headers, URLs, cookies, and even payload.
  • Allows advanced routing like:

    • Send /images/* requests to a media server.
    • Send /api/* requests to a microservices cluster.
  • Supports caching, SSL termination, and compression.

Example Use Case:

  • E-commerce platforms, microservices, API gateways.

Diagram Reference:

  • A customs officer who checks packages and routes them based on contents, not just the label.

Based on Deployment

Hardware Load Balancer

  • Physical appliances (e.g., F5, Citrix ADC).
  • High throughput, low latency, enterprise-grade reliability.
  • Expensive and less flexible compared to cloud/software alternatives.

Use Case:

  • Banks, telecom providers, and enterprises with strict SLAs.

Software Load Balancer

  • Runs on commodity servers or containers.
  • Examples: HAProxy, Nginx, Envoy.
  • Cheaper, flexible, easy to automate.
  • Can be deployed on-prem or in the cloud.

Use Case:

  • Startups and mid-sized businesses needing scalability without heavy upfront costs.

Cloud (Managed) Load Balancer

  • Provided by cloud vendors (AWS ELB, GCP Load Balancing, Azure Front Door).
  • Fully managed: auto-scaling, global routing, DDoS protection.
  • Pay-as-you-go pricing.

Use Case:

  • Cloud-native apps, SaaS platforms, global services.

DNS Load Balancer (Global Load Balancing)

  • Uses DNS resolution to distribute traffic across regions or data centers.
  • Example: GeoDNS – routes users to the closest server for better latency.
  • Works well with CDN and multi-region deployments.

Limitations:

  • DNS caching may delay traffic re-routing.

Use Case:

  • Multi-region applications, disaster recovery setups.

Comparing the Types

Type OSI Layer Flexibility Speed Cost Example Tools
Layer 4 (Transport) L4 Low Very High Medium LVS, HAProxy
Layer 7 (Application) L7 Very High Moderate Medium Nginx, Envoy
Hardware Appliance L4/L7 Medium Very High High F5, Citrix
Software Load Balancer L4/L7 High High Low HAProxy, Nginx
Cloud Managed LB L4/L7/DNS Very High High Pay-as-you-go AWS ELB, GCP LB
DNS Load Balancer DNS Medium High Low Route53, Cloudflare

Best Practices in Choosing a Load Balancer

  • Startups / Small scale: Software LB (HAProxy, Nginx).
  • Cloud-native apps: Managed Cloud LB + CDN.
  • Enterprises / Banks: Hardware LB for compliance & reliability.
  • Global traffic: DNS + Geo-aware routing.
  • APIs / Microservices: Layer 7 LB with SSL termination.

Conclusion

Load balancers come in many flavors—ranging from fast and simple Layer 4 balancers to intelligent Layer 7 balancers, and from hardware appliances to cloud-native managed solutions.

The choice depends on your application scale, budget, compliance needs, and latency requirements.

In Part 3, we’ll explore Load Balancing Algorithms (Round Robin, Least Connections, Consistent Hashing, etc.)—the strategies behind how requests get distributed.


More Details:

Get all articles related to system design
Hastag: SystemDesignWithZeeshanAli

systemdesignwithzeeshanali

Git: https://github.com/ZeeshanAli-0704/SystemDesignWithZeeshanAli

Top comments (0)