Gmane
From: Lugovoi Nikolai <meadow.nnick@...>
Subject: Re: SCGI cluster configuration example for Apache
Newsgroups: gmane.comp.lang.ruby.rails
Date: 2005-12-09 07:21:16 GMT (2 years, 37 weeks, 4 days, 4 hours and 41 minutes ago)
2005/12/8, zedshaw@... <zedshaw@...>:
> You know, I could have swore I did this to test the cluster, but now that
> I look at my setup I think it actually wasn't working with a cluster.  I'm
> actually quite stumped how you'd do this.  In lighttpd you just say
> there's 3 servers and that's it.  It uses them.  In Apache I'm thinking
> you'll have to scgimount the three backends to different URLs, and then
> *somehow* use mod_rewrite to balance between them.
>

One could use random RewriteMap for "balancing". :)
In Apache config:

SCGIMount /scgi0/ 127.0.0.1:9999
SCGIMount /scgi1/ 127.0.0.1:10000
SCGIMount /scgi2/ 127.0.0.1:10001

RewriteMap scginums rnd:/web/scgi-nums.txt

File /web/scgi-nums.txt:

num 0|1|2

And change rewrite rule to "balance" between them:

RewriteRule ^(.*)$ /scgi${scginums:num}/$1 [QSA,L]

Setup Rails routing:
config/routes.rb:

map.connect ':controller/:action/:id'
map.connect 'scgi0/:controller/:action/:id'
map.connect 'scgi1/:controller/:action/:id'
map.connect 'scgi2/:controller/:action/:id'

Now, it will work as a cluster, but it's definitely *very poor* "solution". :)

> That seriously can't be right.  There's got to be a simpler way.  Anyone
> have other thoughts?
>
> Zed
>