LVS feedbackd HOWTO

Proof reading and helpful contributions: Joseph Mack

v2003.07 Jul 2003, released under GPL.


Table of Contents

1. Introduction
1.1. Document Conventions
1.2. Software Versions
1.3. The Network Element Control Protocol
2. Configure LVS and network
3. Deploying the master
3.1. Download and untar
3.2. Configure
3.3. Make
3.4. Install
3.5. Edit master configuration file
3.6. Running feedbackd-master
4. Deploying the agent
4.1. Download and untar
4.2. Configure
4.3. Make
4.4. Install
4.5. Edit agent configuration file
4.6. Running feedbackd-agent
4.7. Monitor Plugins
5. Security
6. Adjusting feedbackd parameters
6.1. Keepalive Intervals
6.2. Keepalive Timeout and Retries
6.3. Master Timeout

Abstract

This document is provided to assist in deploying the feedbackd system on a Linux Virtual Server (LVS) based server cluster. It is assumed that the LVS system is working, and you have a basic understanding of Linux and compiling software packages.

The LVS HOWTO gives a comprehensive guide to setting up an LVS cluster.

The feedbackd system is aimed at improving the performance of a server cluster, by evenly distributing a request load amongst the available servers. It does this by reporting the servers' load to the director, where it is used to allocate subsequent requests to the least busy servers.

To do this, feedbackd is split into two processes - the master, which is run on the director, and the agents, which are run on the servers. The agents and master communicate using the Network Element Control Protocol (NECP).

Feedbackd uses the Network Element Control Protocol (NECP) to communicate load data between master and agents. The NECP specification is available at http://www.circlemud.org/~jelson/writings/draft-cerpa-necp-03.txt. An overview of NECP is available at http://www.circlemud.org/~jelson/writings/necp-ietf/.

A typical NECP session proceeds like this:

  • The master starts, and listens for connections on 3262
  • An agent starts, connects to the master and performs initialisation
  • The agent informs the master of the services that it can provide. This is defined in the configuration file, typically /etc/feedbackd-agent.xml
  • The master registers these services in the ipvs tables, initially with a "weight" of zero, so no requests will be forwarded to the realserver
  • Periodically, the master will ask the agent for its current health status for each of its services. When the reply is received by the master, it updates the ipvs tables with the new data. The NECP specification calls a request for health data a 'KEEPALIVE request'. The reply (which contains the health data) is called a 'KEEPALIVE ACK'.
  • If no response is seen to a keepalive packet, the master resends it. After a predefined number of retries, the realserver is considered dead and quiesced.
  • When an agent is shutdown, it tells the master, which queisces the service (by setting the realserver's weight to zero again) - no new connections will be made to the realserver
  • For any services in the process of quiescing, the master checks the number of active connections to that service on a regular basis. When this number of connections is zero, the service is removed from the ipvs tables.

This procedure outlines a few important concepts:

  • The agents are responsible for finding the master process - so must be configured with the address of the director node. The director has no advance knowlegde of where its realservers will be, or the forwarding type required to send requests to the realserver.
  • The realserver contacts the director with a list of the services it has available for the LVS.
  • These previous two points allow some nice functionality - no reconfiguration needs to be done to the director when new realservers are added to the cluster. New realservers can be added by plugging them into the network and running the agent. Similarly, to remove a realserver, the agent is halted - after all existing connections have been processed, the realserver can be removed.

To deploy feedbackd, you must have a working LVS-based cluster. Any type of forwarding type will work, as long as your network topology allows the realservers to establish a tcp session to port 3262 on the director.

The master process is installed on the director - its role is to listen for connections from the agents, and update the director's ipvs tables with health values reported by the agents

The master requires the libxml2 library to parse configuration data. If installing from a package-management system (for example, .rpm or .deb), you'll need the libxml2 development package.

Generally, these are the steps required (the arguments to configure are only a guide):

director:$ tar zxvf feedbackd-master-0.3.1.tar.gz
director:$ cd feedbackd-master-0.3.1
director:$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
director:$ make
director:$ su 
director:# make install
director:# $EDITOR /etc/feedbackd-master.xml
director:# feedbackd-master -t
director:# feedbackd-master

The feedbackd-master source distribution is available from http://www.redfishsoftware.com.au/projects/feedbackd/. Untar the files into a build directory:

director:$ tar zxvf feedbackd-master-0.3.1.tar.gz
director:$ cd feedbackd-master-0.3.1

The feedbackd distribution is built using the autoconf and automake tools, so configuration is fairly standard:

director:$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var

Feel free to use other values for the prefix or sysconfdir paths, although this document assumes these options are used - you'll need to change the paths of subsequent commands.

Options to configure:

If configure completes without errors, skip to the next section

Otherwise, if you get the following error:

 configure: error: cannot find net/ip_vs.h in your kernel source. 

then the ipvs headers are not installed in the expected location. There are a few possible reasons:

If you get the following error:

 configure: error: cannot find ipvs/ipvs.h. Is ipvsadm installed?

or

 configure: error: cannot find libipvs library. Is ipvsadm installed?

then ipvsadm has not installed its header files and/or library in an accessible location. If you have not installed ipvsadm, do that now. Otherwise, you have two options here (where $ipvsadm_root is where you have extracted the ipvsadm tarball):

The master configuration file is installed in /etc/feedbackd-master.xml by default. It's in XML format, and is fairly simple at present.

Here is the sample configuration file:

<?xml version="1.0"?>

<!-- configuration file for a feedbackd-master process -->
<feedbackd-master>

 <!-- log configuration -->
 <log>
  <!-- where to log to -->
  <file>/var/log/feedbackd-master.log</file>
  <!-- log level. one of CRIT, ERR, WARN, INFO, DEBUG or VDEBUG -->
  <level>WARN</level>
 </log>

 <!-- settings for the scheduler -->
 <scheduler>
  <!-- the time (in seconds) between periodic health checks ('keepalive'
       messages) smaller values will give more up-to-date load information,
       but will increase network load -->
  <keepalive_interval>2</keepalive_interval>
  <!-- how long (in seconds) before we consider a keepalive to be lost. After
       sucessive (keepalive_retries) lost keepalive requests, the server is
       considered dead and is quiesced -->
  <keepalive_timeout>10</keepalive_timeout>
  <!-- number of keepalive packets to retry before considering a server dead
       -->
  <keepalive_retries>3</keepalive_retries>
  <!-- when a server is quiesced, it isn't removed from ipvs tables immediately,
       as it may have active connections. feedbackd will check for active
       connections every removal_interval seconds, and if the value is 0, 
       remove it. -->
  <removal_interval>30</removal_interval>
 </scheduler>

</feedbackd-master>

At present, the logging options are the only ones you need to worry about - the scheduler settings are covered in Section 6

When the master is informed that a realserver is available, it gets a list of the services running on that host. For each of these services, it looks for a matching virtual service in the director's ipvs tables. Therefore, you need to setup these virtual services before feedbackd-master is run, using ipvsadm -A. The following example will add a virtual service on the VIP for http (tcp port 80) requests:

director:# ipvsadm -A -t VIP:http -s rr

Now you can run the master process. If you have compiled with ipvs support (the default behaviour, without the --without-ipvs option to ./configure), you will need to be root to run it.

director:# feedbackd-master 

feedbackd-master will parse the configuration, and if all is ok, run in the background. You can view the logs by:

director:# tail -f /var/log/feedbackd-master.log 

To stop the process, issue a:

director:# killall feedbackd-master 

Note
The default behaviour on exit is to leave the ipvs tables as they are - the realservers will be weighted with the last value that was set. In the future (if there is any demand to do so), signals may be used to define the behaviour on exit (adjust all weights to be equal?)

An agent process is installed on each realserver in the cluster to monitor realserver health and report it back to the master. The metric used to define health is configurable - a plugin is used to perform the actual measurement. The agents are also responsible for informing the master which services are available on each host.

An agent is required on each realserver. To start, you can setup and test the agent on one realserver, then copy the files to the other realservers.

Like the master, the agent requires the libxml2 library to parse configuration data. Also, perl is required for the perl.so plugin

The agent is installed in a similar way to the master:

realserver:$ tar zxvf feedbackd-agent-0.3.1.tar.gz
realserver:$ cd feedbackd-agent-0.3.1
realserver:$ ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
realserver:$ make
realserver:$ su 
realserver:# make install
realserver:# $EDITOR /etc/feedbackd-agent.xml
realserver:# feedbackd-agent -t
realserver:# feedbackd-agent

The feedbackd-agent source distribution is available from http://www.redfishsoftware.com.au/projects/feedbackd/. Untar the files into a build directory:

realserver:$ tar zxvf feedbackd-agent-0.3.1.tar.gz
realserver:$ cd feedbackd-agent-0.3.1

The agent configuration file is installed in /etc/feedbackd-agent.xml by default. You'll need to change (at least) the director IP address, and perhaps the service definitions.

Here is the sample configuration file:

<?xml version="1.0"?>

<!-- configuration file for a feedbackd-agent process -->
<feedbackd-agent>

 <!-- log configuration -->
 <log>
  <!-- where to log to -->
  <file>/var/log/feedbackd-agent.log</file>
  <!-- log level. one of CRIT, ERR, WARN, INFO, DEBUG or VDEBUG -->
  <level>WARN</level>
 </log>

 <!-- how many connection attempts (to the master) to make before giving up.
      0 = never give up (default) -->
 <connection-retries>0</connection-retries>

 <!-- where to find monitor plugins -->
 <moduledir>/lib/feedbackd-agent/</moduledir>

 <!-- where to connect to the master process. Either a hostname or an IP -->
 <director>$DIP</director>

 <!-- the defintion of a service. the name attribute is symbolic -->
 <service name="http">
  
  <!-- IP subprotocol to use, eg tcp or udp -->
  <protocol>tcp</protocol>
  
  <!-- port the service runs on. numeric ('80') or symbolic ('http').  -->
  <port>http</port>
  
  <!-- forwarding type, either DR, TUN or NAT -->
  <forwarding>NAT</forwarding>

  <!-- plugin to use for load monitoring. The contents of this
       tag are passed to the monitor plugin to handle. -->
  <monitor plugin="cpuload.so">
  </monitor>
  
 </service>
</feedbackd-agent>

Because the definition of "realserver health" changes between applications, feedbackd-agent uses dynamically-loaded plugins to measure the health of a service. Plugins can be added without requiring the agent to be rebuilt, and allow development of monitor plugins for custom applications. At present, the following plugins are available:

Contributions for new plugins are welcome - either as a suggestion for development or a full implementation.

Because the feedbackd-master accepts connections from all remote hosts, it is possible for a malicious agent to connect to the master and add a realserver entry to the ipvs tables. This would allow a denial-of-service or man-in-the-middle attack on the services provided by the cluster. Therefore, it is important to block connections from unknown hosts to the director on tcp port 3262.

There are a number of parameters that allow optimisation of feedbackd behaviour to suit specific applications and network topologies.