Linux Load Balancing and Failover

Evidian SafeKit brings network load balancing and failover to Linux applications. This article explains how to implement quickly a Linux load balancing cluster without network boxes or dedicated load balancing servers. A free trial is offered.

How the Evidian SafeKit software simply implements Linux load balancing and failover without network load balancers or dedicated servers

How the Evidian SafeKit farm cluster implements Linux load balancing and failover?

On the previous figure, the Linux application is running of the 3 servers. Users are connected to a virtual IP address which is configured locally on each server. The input traffic for the virtual IP address is received by all the servers and split among them by a filter inside each server's kernel.

The network load balancing algorithm inside the filter is based on the identity of the client packets (client IP address, client TCP port). Depending on the identity of the client packet input, only one filter in a server accepts the packet; the other filters in other servers reject it.

Once a packet is accepted by the filter on a server, only the CPU and memory of this server are used by the Linux application that responds to the request of the client. The output messages are sent directly from the Linux server to the client.

If a server fails, the SafeKit membership protocol reconfigures the filters in the network load balancing cluster to re-balance the traffic on the remaining available servers.

Note that SafeKit works in VMware environments without the Microsoft NLB problems of unicast and muticast modes.  And note also that SafeKit network load balancing is working not only on Windows (including Windows editions for PCs) but also on Linux.

Configuration overview of Linux load balancing and failover

With SafeKit, you can configure either a farm application module or a mirror application module according the high availability architecture suited for an application. For Linux load balancing and failover, the right module is the farm module.

Configuration overview of Linux load balancing and failover

The configuration files for Linux load balancing and failover are given here.

They include:

1. the Linux application stop and start scripts,

2. the configuration file userconfig.xml which contains:

SafeKit configuration files for Linux load balancing and failover

Installation instructions

Note: Examples of application modules built from this generic module are given here.

userconfig.xml

<!DOCTYPE safe>
<safe>
<service mode="farm" maxloop="3" loop_interval="24">
  <!-- Farm topology configuration for the membership protocol -->
  <!-- Names or IP addresses on the default network are set during initialization in the console -->
  <farm>
    <lan name="default" />
  </farm>
  <!-- Virtual IP Configuration -->
  <!-- Replace
     * VIRTUAL_IP_ADDR_TO_BE_DEFINED by the IP address of your virtual server 
  -->
  <vip>
    <interface_list>
      <interface check="on" arpreroute="on">
        <virtual_interface type="vmac_directed">
          <virtual_addr addr="VIRTUAL_IP_ADDR_TO_BE_DEFINED" where="alias"/>
        </virtual_interface>
      </interface>
    </interface_list>
    <loadbalancing_list>
      <group name="Windows_Appli">
        <!-- Set load-balancing rule on the TCP port of the service to load balance -->
        <rule port="TCP_PORT_TO_BE_DEFINED" proto="tcp" filter="on_addr"/>
      </group>
    </loadbalancing_list>
  </vip>
  <!-- TCP Checker Configuration -->
  <!-- Replace
     * VIRTUAL_IP_ADDR_TO_BE_DEFINED by the IP address of your virtual server 
     * TCP_PORT_TO_BE_DEFINED by the TCP port of the service to check
  -->
  <check>
    <tcp ident="Check_Appli" when="both">
      <to
         addr="VIRTUAL_IP_ADDR_TO_BE_DEFINED"
         port="TCP_PORT_TO_BE_DEFINED"
         interval="10"
         timeout="5"
       />
    </tcp>
  </check>
  <!-- User scripts activation -->
  <user nicestoptimeout="300" forcestoptimeout="300" logging="userlog" />
</service>
</safe>

start_both

#!/bin/sh
# Script called on the primary server for starting application

# For logging into SafeKit log use:
# $SAFE/safekit printi | printe "message" 

# stdout goes into Application log
echo "Running start_both $*" 

res=0

# Fill with your application start call

if [ $res -ne 0 ] ; then
  $SAFE/safekit printe "start_both failed"

  # uncomment to stop SafeKit when critical
  # $SAFE/safekit stop -i "start_both"
fi

stop_both

#!/bin/sh
# Script called on the primary server for stopping application

# For logging into SafeKit log use:
# $SAFE/safekit printi | printe "message" 

#----------------------------------------------------------
#
# 2 stop modes:
#
# - graceful stop
#   call standard application stop
#
# - force stop ($1=force)
#   kill application's processes
#
#----------------------------------------------------------

# stdout goes into Application log
echo "Running stop_both $*" 

res=0

# default: no action on forcestop
[ "$1" = "force" ] && exit 0

# Fill with your application stop call

[ $res -ne 0 ] && $SAFE/safekit printe "stop_both failed"

Demonstration

This demonstration is made with Apache on Windows but the operating mode is the same as with a Linux application.

More on SafeKit

Other examples of high availability modules:

Mirror modules

Windows

Linux

Microsoft SQL ServerWindows module-
OracleWindows moduleLinux module
MySQLWindows moduleLinux module
PostgreSQLWindows moduleLinux module
FirebirdWindows moduleLinux module
Hyper-VWindows module-
Hanwha SSMWindows module-
Milestone XProtectWindows module-
Generic moduleWindows moduleLinux module

Farm modules

Windows

Linux

IIS moduleWindows module-
Apache moduleWindows moduleLinux module
Generic moduleWindows moduleLinux module
contact
CONTACT
Demonstration

Evidian SafeKit Pricing





White Papers

contact
NEWS

To receive Evidian news, please fill the following form.