session

~/chopper

article

IPVS

IPVS is a high-performance layer 4 load balancer implemented inside linux kernel. It is designed efficiently to distribute incoming traffics across multiple backend servers. IPVS operates by defining a Virtual Server with public facing IP address and port and a set of backend servers. IPVS intercepts the incoming traffics and forwards the traffics to the appropriate backend server using load balancing algorithm.

The flow of packets through the IPVS can be summarised as follow. When a client sends a request to the virtual server using virtual IP, traffic flows into the kernel and IPVS intercepts the request and find the Virtual server that the traffic request was destinated to. Then, IPVS selects the backend server using load balancing algorithm and forward the traffic to it.

IPVS supports multiple load balancing algorithms, including: Round Robin which cycles through a serie of servers sequentially. Least Connection which selects the server with fewest active connections. Weighted Load Balancer which prioritises the specific server among others to route the traffics. Source Hashing which is used to maintain persistent session.

IPVS supports different methods for forwarding traffics. Direct Routing (DR) where backend send the traffic to the client directly. NAT Mode is used to modified the source or destination IP address of the packets. Tunnelling (TUN) is used for where packets were encapsulated and sent across networks.