Operations 7 min read

Three LVS Load‑Balancing Modes and Eight Scheduling Algorithms

The article explains the three LVS load‑balancing modes—NAT, IP tunnel, and direct routing—and details eight scheduling algorithms, including round‑robin, weighted round‑robin, least‑connection, weighted least‑connection, locality‑based, locality‑based with replication, destination‑hashing, and source‑hashing, highlighting their principles and use cases.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Three LVS Load‑Balancing Modes and Eight Scheduling Algorithms

LVS (Linux Virtual Server) implements IP load balancing within the Linux kernel, offering high‑efficiency traffic distribution across real servers. It supports three primary load‑balancing modes:

NAT mode : The director (DR) rewrites the destination IP address of incoming packets to that of a selected real server, forwards the packet, and then rewrites the source address of the response before sending it back to the client. All traffic passes through the director.

IP tunnel mode : Similar to a VPN, the director encapsulates the original packet with a new IP header and sends it to the real server. The real server decapsulates the packet, processes it, and replies directly to the client, bypassing the director. This mode requires the real server to support the IPTUNNEL protocol.

Direct routing mode : Both the director and real servers share the same virtual IP address, but only the director answers ARP requests. The director changes the destination MAC address to that of the chosen real server and forwards the packet at layer‑2. The real server sees the packet as if it arrived directly from the client and replies directly, so traffic between director and real server stays within the same broadcast domain.

The LVS framework provides eight scheduling algorithms:

1. Round‑Robin Scheduling : Distributes requests sequentially across all real servers, treating each server equally regardless of load.

2. Weighted Round‑Robin Scheduling : Assigns weights to servers based on their processing capacity, directing more traffic to higher‑weight servers.

3. Least‑Connection Scheduling : Sends each request to the server with the fewest active connections, suitable when servers have similar performance.

4. Weighted Least‑Connection Scheduling : Combines weighting with the least‑connection principle, favoring higher‑capacity servers while considering current connections.

5. Locality‑Based Least‑Connection Scheduling (LBLC) : Targets cache clusters by routing requests to the server that most recently served the same destination IP, falling back to the least‑connection rule if needed.

6. Locality‑Based Least‑Connection with Replication Scheduling (LBLCR) : Extends LBLC by maintaining a mapping from a destination IP to a group of servers, selecting the least‑loaded server within the group and dynamically adjusting the group composition.

7. Destination‑Hashing Scheduling : Uses the destination IP address as a hash key to select a server from a static hash table, sending the request to the mapped server if it is available.

8. Source‑Hashing Scheduling : Similar to destination‑hashing but hashes the source IP address, directing traffic from the same client consistently to the same server.

operationsload balancingNetworkingscheduling algorithmsLVSipvs
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.