Load balancing

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
m (Load Balancing Configuration moved to Load balancing)
(renamed tag to directive)
Line 59: Line 59:
 
= Sharing Cluster configuration: cluster.xml and <[[resin:import]]> =
 
= Sharing Cluster configuration: cluster.xml and <[[resin:import]]> =
  
Many sites will create a separate cluster.xml using resin's resin:import tag to share information between the frontend and backend:
+
Many sites will create a separate cluster.xml using resin's resin:import directive to share information between the frontend and backend:
  
 
==== cluster.xml ====
 
==== cluster.xml ====

Revision as of 20:22, 21 February 2006


Resin documentation is at http://www.caucho.com/resin-3.0/config/balance.xtp

Load balancing spreads the load among multiple backend Resin servers in a Cluster. A frontend Resin server proxies requests to the backend servers and sends the results to the clients.

We'll use 192.168.0.10 as the frontend machine and 192.168.0.20 through 192.168.0.28 as the backend machines.

The frontend server and the backend cluster have different configurations since they perform different roles.

Contents

The Frontend Server

  1. dispatches requests to the backend servers, generally using sticky sessions
  2. acts as a Proxy Cache for the backend cluster
  3. pools the proxy sockets for efficiency

== The Backend Cluster

  1. does the actual work: the database querying and form processing
  2. manages persistent sessions

Frontend Configuration

The frontend needs to configure:

  1. The external HTTP and HTTPS ports its listening to
  2. The cluster-definition of the backend cluster
  3. A LoadBalanceServlet to dispatch requests to the backend

frontend.conf

<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="http://caucho.com/ns/resin/core">
  <server>
    <http host="*" port="80"/>

    <cluster-definition id="backend">
      <client-live-time>15s</client-live-time>

      <srun id="a" host="192.168.0.20" port="6802"/>
      <srun id="b" host="192.168.0.21" port="6802"/>
    </cluster-definition>

    <cache memory-size="32M"/>

    <host id="">
      <web-app id="">
        <servlet servlet-name="balance"
                 servlet-class="com.caucho.servlets.LoadBalanceServlet">
          <init>
            <cluster>backend</cluster>
          </init>
        </servlet>

        <servlet-mapping url-pattern="/*" servlet-name="balance"/>
      </web-app>
    </host>
  </server>
</resin>

Sharing Cluster configuration: cluster.xml and <resin:import>

Many sites will create a separate cluster.xml using resin's resin:import directive to share information between the frontend and backend:

cluster.xml

<cluster>
  <client-live-time>30s</client-live-time>

  <srun id="a" host="192.168.0.20" port="6802"/>
  <srun id="b" host="192.168.0.21" port="6802"/>
</cluster>

In the frontend.conf, you'll replace the <cluster-definition> content with a <resin:import>

frontend.xml

<server>
  ...
  <cluster-definition id="backend">
    <resin:import path="${resin.rootDir}/conf/cluster.xml"/>
  </cluster-definition>
  ...
</server>
Personal tools