Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

High-Availability Deployment Using Linux Virtual Server

Tech May 8 3

Linux Virtual Server (LVS) functions as a kernel-level layer 4 load balancer within the Linux ecosystem. It distributes incoming network traffic across a pool of backend servers to ensure reliability, scalability, and optimal performance. This guide outlines the installation procedures, module management, and operational configurations for NAT and Direct Routing modes.

Prerequisites and Module Loading

Install the ipvsadm user-space utility using your distribution's package manager.

Debian/Ubuntu:

apt-get update && apt-get install -y ipvsadm

CentOS/RHEL:

yum install -y ipvsadm

Ensure the IP Virtual Server kernel modules are active before defining services:

modprobe ip_vs
modprobe ip_vs_rr
modprobe ip_vs_wrr
modprobe ip_vs_sh

Verify the current status of virtual services with:

ipvsadm -Ln

Network Adress Translation (NAT)

In NAT mode, the director acts as the default gateway for all requests. It rewrites the destination address of packets before forwarding them to Real Servers (RS). Return traffic is routed back through the director where source addresses are restored. This method supports external IPs without configuration on the RS.

Director Configuration

Define the virtual service (VIP) on port 80 using round-robin scheduling:

ipvsadm -A -t 192.168.50.10:80 -s rr

Real Server Configuration

Add the backend nodes to the virtual service list. Enable masquerading to handle return traffic translation:

ipvsadm -a -t 192.168.50.10:80 -r 192.168.50.11:80 -m --masquerade

Direct Routing (DR)

Direct Routing allows the Real Servers to reply directly to clients, bypassing the load balancer for outbound traffic. This reduces latency and load on the director hardware. A key requirement is that both the VIP and the subnet must be present on the local interface of the Real Servers, typically configured via loopback enterfaces.

Director Configuration

Establish the virtual service entry similar to NAT mode:

ipvsadm -A -t 192.168.50.10:80 -s rr

Real Server Configuration

Register the backend nodes without masquerading flags:

ipvsadm -a -t 192.168.50.10:80 -r 192.168.50.11:80

Ensure the load balancer does not ARP for the VIP on the real server side. The RS binds the VIP to a dummy or loopback interface to accept traffic while preventing ARP conflicts on the LAN.

Monitoring and Maintenance

Regularly inspect the active service lists to verify scheduler behavior. Use tools like watch combined with ipvsadm -Ln to monitor session counts and weight adjustments dynamically during peak traffic periods.

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.