Forum: Ruby on Rails SCGI cluster configuration example for Apache

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
francois.beausoleil (Guest)
on 2005-12-07 20:02
(Received via mailing list)
Hi all !

I have SCGI setup and working correctly on a new host.  I configured a
cluster using:
  scgi_cluster config -e production -p 20000 -c 2

Now, I want to tell mod_scgi that I have two children.  How do I do
that ?  I can't seem to find anything on the SRR site, nor on the
mailing list.

Thanks for any tips !
zedshaw (Guest)
on 2005-12-07 23:33
(Received via mailing list)
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.

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

Zed
meadow.nnick (Guest)
on 2005-12-09 08:21
(Received via mailing list)
2005/12/8, zedshaw@zedshaw.com <zedshaw@zedshaw.com>:
> 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". :)
This topic is locked and can not be replied to.