Resin Load Balancing

From Resin 3.0

Revision as of 22:59, 2 October 2010 by Ferg (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


When your load reaches more than one application server can handle, you need a HTTP load balancer to distribute the load to the application servers. Resin's own load balancing, combined with its proxy cache support, makes it a solid choice for the load balancer as well as the backend servers.

resin.xml for load balancing

  • single configuration file: one cluster for the web server and one for the application servers
  • proxy cache on the web server to improve performance
  • using /var/www/webapps for the content. For other directory structures, see other examples.
  • HTTP servers using IP addresses 192.168.1.*
  • HTTP servers using IP addresses 192.168.2.*
<resin xmlns="http://caucho.com/ns/resin">
       xmlns:resin="urn:java:com.caucho.resin">

  <cluster id="web-tier">
    <server id="web-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="">
      <access-log path="log/access.log"/>

      <web-app id="">

        <resin:LoadBalance cluster="app-tier"/>

      </web-app>
    </host>
  </cluster>

  <cluster id="app-tier">
    <resin:import path="${__DIR__}/app-default.xml"/>

    <server id="app-a" address="192.168.2.10" port="6800"/>
    <server id="app-b" address="192.168.2.11" port="6800"/>
    <server id="app-c" address="192.168.2.12" port="6800"/>

    <host id="">
      <web-app-deploy path="webapps/"/>
    </host>
  </cluster>
 </resin>
  • cluster web-tier is the HTTP cluster
  • cluster app-tier is the backend application server cluster
  • the proxy-cache on the HTTP tier caches data from the backend tier
  • the web-tier listens to port 80
  • the app-tier listens to internal cluster port 6800
  • the resin:LoadBalance forwards all content to the backend tier as a rewrite rule
  • default servlet behavior like JSP, PHP, and static file processing is included with the app-default.xml
  • /var/www/webapps contains the web-app content
Personal tools