Load Balancing

Load balancing is the strategic distribution of network traffic across multiple servers or resources to optimize performance, enhance reliability, and ensure...

Load balancing is a fundamental technique in distributed systems and network architecture used to distribute incoming network traffic across multiple backend servers or resources. The primary goal is to optimize resource utilization, maximize throughput, minimize response time, and avoid overloading any single resource. Load balancers operate at various layers of the OSI model, with Layer 4 (Transport Layer) and Layer 7 (Application Layer) being the most common. Layer 4 load balancers typically make routing decisions based on IP addresses and port numbers, offering high performance and simplicity. Layer 7 load balancers, on the other hand, can inspect the content of the traffic (e.g., HTTP headers, URLs) to make more intelligent routing decisions, enabling features like SSL termination, content-based routing, and session persistence. Common algorithms include Round Robin, where requests are distributed sequentially; Least Connections, which directs traffic to the server with the fewest active connections; and IP Hash, which uses a hash of the client's IP address to ensure requests from the same client consistently go to the same server. Advanced techniques involve health checks to detect and remove unhealthy servers from the pool, ensuring high availability and fault tolerance. Trade-offs involve complexity, cost, and potential single points of failure if the load balancer itself is not redundant.

        graph LR
  Center["Load Balancing"]:::main
  Rel_advanced_propulsion_systems["advanced-propulsion-systems"]:::related -.-> Center
  click Rel_advanced_propulsion_systems "/terms/advanced-propulsion-systems"
  Rel_content_delivery_network["content-delivery-network"]:::related -.-> Center
  click Rel_content_delivery_network "/terms/content-delivery-network"
  Rel_distributed_systems["distributed-systems"]:::related -.-> Center
  click Rel_distributed_systems "/terms/distributed-systems"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧒 Explain Like I'm 5

Imagine a popular restaurant with many waiters. Load balancing is like a host who directs new customers to the waiter who has the fewest tables to serve, so everyone gets their food faster and no single waiter gets overwhelmed.

🤓 Expert Deep Dive

Load balancing is the strategic distribution of network traffic across multiple servers or resources to optimize performance, enhance reliability, and ensure high availability by preventing any single point of failure and managing resource utilization effectively.

📚 Sources