Two Cluster Load Balancing

From Resin 3.0

Revision as of 17:35, 21 October 2011 by Pcowan (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Some sites with multiple virtual hosts may want to load balance to two separate backend clusters. For example, a www.foo.com might have 3 servers in its backend cluster and www.bar.com might only have 1 server in its backend cluster. Because Resin's <resin:LoadBalance> tag is flexible, you can use it to split the traffic as your site needs.

resin.xml for www.foo.com and www.bar.com

This configuration has 5 servers in three separate clusters defined in a single resin.xml file. Although you can split the configuration into multiple files using <resin:import>, the basic single-file configuration is designed so you can review the entire system at once, instead of managing lots of configuration files.

Features:

  • HTTP load balancing on port 80 of server 192.168.1.10 (the web-tier)
  • www.foo.com handled by 3 servers: 192.168.2.10, 192.168.2.11, 192.168.2.12
  • www.bar.com handled by 1 server: 192.168.3.10
  • proxy-cache enabled on the web-tier, improving performance for all servers
  • the web-tier server runs as "resin" user for security

resin.xml

<resin xmlns="http://caucho.com/ns/resin">
       xmlns:resin="urn:java:com.caucho.resin">
 
  <cluster-default>
    <resin:import path="${__DIR__}/app-default.xml"/>
  </cluster-default>

  <cluster id="web-tier">

    <server id="http-a" address="192.168.1.10" port="6800">
      <http port="80"/>
      <user-name>resin</user-name>
      <group-name>resin</group-name>
    </server>

    <proxy-cache/>

    <host id="www.foo.com">
      <web-app id="/">
        <resin:LoadBalance regexp="^" cluster="foo-tier"/>
      </web-app>
    </host>

    <host id="www.bar.com">
      <web-app id="/">
        <resin:LoadBalance regexp="^" cluster="bar-tier"/>
      </web-app>
    </host>
  </cluster>

  <cluster id="foo-tier">
     <server id="foo-a" address="192.168.2.10" port="6800"/>
     <server id="foo-b" address="192.168.2.11" port="6800"/>
     <server id="foo-c" address="192.168.2.12" port="6800"/>
 
     <host id="/" root-directory="/var/www/www.foo.com">
       <web-app-deploy path="webapps"/>
     </host>
  </cluster>


  <cluster id="bar-tier">
     <server id="bar-a" address="192.168.3.10" port="6800"/>
 
     <host id="/" root-directory="/var/www/www.bar.com">
       <web-app-deploy path="webapps"/>
     </host>
  </cluster>
 </resin>
Personal tools