Chapter 43. Load Balancing with Enhydra Director

  1. Download the Tomcat (or Jetty) module from the ObjectWeb site http://director.objectweb.org/index.html.

  2. Download the binaries or sources for the Apache module.

    NoteNote
     

    You can also download an entire distribution of the Apache webserver in which the module is already included and configured.

  3. Configure the Apache director module in the file: $APACHE_HOME/conf/enhydra_director.conf

    Example configuration:

    <?xml version="1.0"?>
    <!DOCTYPE EnhydraDirectorConfig SYSTEM "EnhydraDirectorConfig.dtd">
    <EnhydraDirectorConfig>
        <Application prefix="/sampleCluster2/">
            <AppServer host="localhost" port="9999" weight="1" />
            <AppServer host="localhost" port="8888" weight="1" />
        </Application>
        <Status prefix="/status">
            <Restrict server="127.0.0.1" />
            <Restrict client="127.0.0.1" />
        </Status>
    </EnhydraDirectorConfig>

    NoteNote
     

    In this configuration, the connector is configured to forward the requests for one web application (load-balancing and fail-over). The second (sampleCluster2 example) is running on one machine, but on different ports. Furthermore, the /status context allows you to enable, disable, and change some parameters of the director configuration. The /status context is only available on the machine where director is running in this sample configuration.

  4. Copy the tomcat module (tomcat-director.jar) to $CATALINA_HOME/server/lib or $JONAS_BASE/lib/catalina/server/lib.

    NoteNotes
     

    • For the JOnAS+Tomcat package, use:$JONAS_BASE/lib/catalina/server/lib

    • For a standalone Tomcat installation use: $CATALINA_HOME/server/lib

  5. Configure the connector in the tomcat configuration ($CATALINE_HOME/conf/server.xml).

    Example configuration:

    Add these lines to the configuration where the other connectors (AJP, ...) are defined:

    Using TomCat 5.0.x as the servlet container:

    <!-- Define a Director Connector on port 8888 -->
    <Connector 
     className =
      "org.enhydra.servlet.connectionMethods.EnhydraDirector. \
       EnhydraDirectorConnectionMethod"
     port = "8888"
     threadTimeout = "300"
     clientTimeout = "30"
     sessionAffinity = "false"
     queueSize = "400"
     numThreads = "200"
     bindAddress = "(All Interfaces)"
     authKey = "(Unauthenticated)"
    />

    Using TomCat 5.5.x as the servlet container:

    <!-- Define a Director Connector on port 8888 -->
    <Connector 
     className = 
      "org.enhydra.servlet.connectionMethods.EnhydraDirector. \
       DirectorProtocol"
     port = "8888"
     threadTimeout = "300"
     clientTimeout = "30"
     sessionAffinity = "false"
     queueSize = "400"
     numThreads = "200"
     bindAddress = "(All Interfaces)"
     authKey = "(Unauthenticated)"
    />

    NoteNote
     

    The session affinity attribute is set to false because the session replication is activated in JOnAS. Otherwise, a new session is created when Director switches between the instances. The Director connector can coexist with the mod_jk connector.

  6. Restart Apache.

  7. Restart JOnAS.