[Seaside] Load Balancing Multiple Seaside Images with mod_proxy_balancer [was: Server Identification in Session Keys]

Sven Van Caekenberghe sven at beta9.be
Sat Aug 21 12:57:37 UTC 2010

Great writeup, Philippe, this should definitively go into the book.

I would also vote for including the Seaside-Cluster package into the main Seaside release (it is very small).

Yesterday, I got the following config working, which is very similar to yours:

<VirtualHost *:80>

  DocumentRoot /home/sven/html
  <Directory /home/sven/html>
    Order deny,allow
    Allow from all

  ProxyRequests Off
  ProxyPreserveHost On
  ServerName smalltalk.wolf359.be

  BalancerMember balancer://seaside-cluster route=R1 
  BalancerMember balancer://seaside-cluster route=R2

  ProxyPass /server-status !
  ProxyPass /balancer-manager !
  ProxyPass /files/RedditFileLibrary !
  ProxyPass / balancer://seaside-cluster/ nofailover=on stickysession=_s 
  ProxyPassReverse / balancer://seaside-cluster/ 
  ProxyStatus On

  <Location /balancer-manager>
    SetHandler balancer-manager
    Order deny,allow
    Allow from all

  <Location /server-status>
    SetHandler server-status
    Order deny,allow
    Allow from all

  ErrorLog /home/sven/logs/apache_error.log
  LogLevel warn
  CustomLog /home/sven/logs/apache_access.log combined


I had some trouble with the balancer member's routes not being picked up, I had to write them outside a <Proxy>. 
That was on the following system:


Server version: Apache/2.2.14 (Ubuntu)
Server built:   Apr 13 2010 19:29:28

But maybe I just got apache into a strange state ;-)
My ProxyPassReverse is different, I am not sure which one is correct.

I start each node as follows:


VM_PARAMS="-mmap 32m -vm-display-none -vm-sound-none"

exec setuidgid $USER $VM $VM_PARAMS $IMAGE $ARGS

With node1.st like this:

(WAComancheAdaptor default) stop; port: 8081; start.
WAAdmin makeAllClusteredWith: 'R1'.

This way, the image itself stays identical.
I also serve some static files directly with apache.
They are easily generated with <YourFileLibrarySubclass> deployFiles.

My 2c,


On 21 Aug 2010, at 11:22, Philippe Marschall wrote:

> Hi
> There are several ways to load balance Seaside images, one way is
> Apache 2.2 and mod_proxy_balancer [1]. Compared to other solutions
> it's relatively easy to set up, doesn't modify the response and is
> free of cost. It only needs one small additional Seaside package with
> two classes. Additionally mod_proxy_balancer has some advanced
> features like a manager application, configurable scheduler algorithm
> and load factor.
> When load balancing multiple Seaside images care must be taken that
> all requests that require a particular session are processed by the
> same image because that session is only available in this image
> (unless you're on GemStone). This has to work with and without session
> cookies. This is referred to as sticky sessions because a session
> sticks to its image. mod_proxy_balancer does this by associating each
> image with and id called route or jvmRoute. Seaside has to append this
> route to the session id. mod_proxy_balancer reads the route from the
> request and proxies to the right image. This has the advantage that
> mod_proxy_balancer does not have to keep track of all the sessions and
> does not have to modify the response. Additionally since the mapping
> is defined statically in the the Apache configuration it survives
> server restarts.
> First you need to define your cluster of images. We'll use two images,
> the first one on port 8080 with the route "first" the second on port
> 9090 with route "second". You can of course chose other routes as long
> as they're unique.
> <Proxy balancer://mycluster>
>    BalancerMember  route=first
>    BalancerMember  route=second
> </Proxy>
> Then we'll need to define the actual proxy configuration, this is very
> similar to a single Seaside image behind an Apache.
> ProxyPass / balancer://mycluster/ stickysession=_s|_s nofailover=On
> ProxyPassReverse /
> ProxyPassReverse /
> Note that we configure _s to be the session id for the the URL and the cookie.
> Finally we can optionally add the balancer manager:
> ProxyPass /balancer-manager !
> <Location /balancer-manager>
>    SetHandler balancer-manager
> </Location>
> Putting everything together it looks something like this (we also
> configures server-status):
> <VirtualHost *>
>        ProxyRequests Off
>        ProxyStatus On
>        ProxyPreserveHost On
>        ProxyPass /balancer-manager !
>        ProxyPass /server-status !
>        ProxyPass / balancer://mycluster/ STICKYSESSION=_s|_s
>        ProxyPassReverse /
>        ProxyPassReverse /
>        <Proxy balancer://mycluster>
>                BalancerMember  route=first
>                BalancerMember  route=second
>        </Proxy>
>        <Location /balancer-manager>
>                SetHandler balancer-manager
>                Order Deny,Allow
>                Deny from all
>                Allow from
>                Allow from localhost
>        </Location>
>        <Location /server-status>
>                SetHandler server-status
>                Order Deny,Allow
>                Deny from all
>                Allow from
>                Allow from localhost
>        </Location>
> </VirtualHost>
> Now all that is left is configuring Seaside. First you need to load
> Seaside-Cluster from [2] (only works with Seaside 3.0). Then you need
> to configure each image individually with the correct route. It's
> important that this matches your Apache configuration from above. The
> easiest way to do this is
> WAAdmin makeAllClusteredWith: 'first'
> in the image on port 8080 and
> WAAdmin makeAllClusteredWith: 'second'
> in the image on port 9090.
> That's it, your sticky session cluster ready to go. You can find the
> manager at and the server status on
> [1] http://httpd.apache.org/docs/2.2/mod/mod_proxy_balancer.html
> [2] http://www.squeaksource.com/ajp/
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

More information about the seaside mailing list