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

Lukas Renggli renggli at gmail.com
Sat Aug 21 10:41:34 UTC 2010


Very cool, can we put that into the book? ;-)

Lukas

On 21 August 2010 11:22, Philippe Marschall
<philippe.marschall at gmail.com> 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 http://127.0.0.1:8080  route=first
>    BalancerMember http://127.0.0.1:9090  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 / http://127.0.0.1:8080/
> ProxyPassReverse / http://127.0.0.1:9090/
>
> 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 / http://127.0.0.1:8080/
>        ProxyPassReverse / http://127.0.0.1:9090/
>
>        <Proxy balancer://mycluster>
>                BalancerMember http://127.0.0.1:8080  route=first
>                BalancerMember http://127.0.0.1:9090  route=second
>        </Proxy>
>
>        <Location /balancer-manager>
>                SetHandler balancer-manager
>
>                Order Deny,Allow
>                Deny from all
>                Allow from 127.0.0.1
>                Allow from localhost
>        </Location>
>
>        <Location /server-status>
>                SetHandler server-status
>
>                Order Deny,Allow
>                Deny from all
>                Allow from 127.0.0.1
>                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 http://127.0.0.1/balancer-manager and the server status on
> http://127.0.0.1/server-status
>
>
>  [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
>



-- 
Lukas Renggli
www.lukas-renggli.ch


More information about the seaside mailing list