# SCGI, Rails and Apache

**URL:** <https://www.ruby-forum.com/t/scgi-rails-and-apache/118304>\
**Category:** Rails\
**Created:** [October 25, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304 "2007-10-25T15:06:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 25, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/1 "2007-10-25T15:06:25Z")

</div>

Hello,  
I have a rails project going with SCGI running to speed it up.  
This normally works fine and is very quick compared to rails on its own.  
But there are times when I may be try (during testing) to upload or  
download very large files and it just stops working dead. Apache seems  
to times out (after about 5 min), but for some reason the SCGI process  
never seems to recover, or time out, and it brings down the whole  
system.  
Is there a way of setting a timeout in Zed S.s SCGI config? so that it  
just times out that connection instead of bring it all down.

On another point, not far from this one, has anyone set up a cluster of  
scgi process and integrated them into apache with some sort of load  
balancing method at all? Any examples?

Cheers.  
Dan.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 25, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/2 "2007-10-25T17:43:04Z")

</div>

Fish Man wrote:

> Hello,  
> I have a rails project going with SCGI running to speed it up.  
> This normally works fine and is very quick compared to rails on its own.  
> But there are times when I may be try (during testing) to upload or  
> download very large files and it just stops working dead. Apache seems  
> to times out (after about 5 min), but for some reason the SCGI process  
> never seems to recover, or time out, and it brings down the whole  
> system.  
> Is there a way of setting a timeout in Zed S.s SCGI config? so that it  
> just times out that connection instead of bring it all down.

I’m not sure if there is a way to set it in Apache. In lighttpd, its  
“disable-time” =\> 0.

> On another point, not far from this one, has anyone set up a cluster of  
> scgi process and integrated them into apache with some sort of load  
> balancing method at all? Any examples?

Install the most current scgi and ruby-style gems. You can set a  
cluster to run on multiple ports or a single port. The web server  
configuration is the exactly same with single port clustering as it is  
with running a single scgi listener. With either type of clustering,  
you can restart without losing requests. Read the README that comes  
with the ruby-style gem for details.

I took over the SCGI project from Zed S., so feel free to ask me any  
questions about it.

Jeremy

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 26, 2007, 10:19am UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/3 "2007-10-26T10:19:05Z")

</div>

Jeremy E. wrote:

> Install the most current scgi and ruby-style gems. You can set a  
> cluster to run on multiple ports or a single port. The web server  
> configuration is the exactly same with single port clustering as it is  
> with running a single scgi listener. With either type of clustering,  
> you can restart without losing requests. Read the README that comes  
> with the ruby-style gem for details.
> 
> I took over the SCGI project from Zed S., so feel free to ask me any  
> questions about it.
> 
> Jeremy

Hi thanks for your advice.  
I think that I understand how to start up clusters for scgi with  
scgi\_cluster, that seems to be well documented.  
But im not exactly sure what do I need to put into Apache to distribute  
the load to each of the different processes. There seems to be a good  
example for lighthttd is there an example avalable for apache2?

Cheers.  
Dan.

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [October 29, 2007, 4:36pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/4 "2007-10-29T16:36:32Z")

</div>

Fish Man wrote:

> Jeremy E. wrote:
> 
> > Install the most current scgi and ruby-style gems. You can set a  
> > cluster to run on multiple ports or a single port. The web server  
> > configuration is the exactly same with single port clustering as it is  
> > with running a single scgi listener. With either type of clustering,  
> > you can restart without losing requests. Read the README that comes  
> > with the ruby-style gem for details.
> > 
> > I took over the SCGI project from Zed S., so feel free to ask me any  
> > questions about it.
> > 
> > Jeremy
> 
> Hi thanks for your advice.  
> I think that I understand how to start up clusters for scgi with  
> scgi\_cluster, that seems to be well documented.  
> But im not exactly sure what do I need to put into Apache to distribute  
> the load to each of the different processes. There seems to be a good  
> example for lighthttd is there an example avalable for apache2?

scgi\_cluster hasn’t worked since 0.4.3, and that version doesn’t support  
single-port clustering, which seems to be a requirement if you want to  
use SCGI with Apache. As I said earlier, install the most current scgi  
and ruby-style gems, and read the README that comes with ruby-style. It  
has deployment instructions as well as a sample Apache configuration.

Jeremy

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [November 2, 2007, 3:06pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/5 "2007-11-02T15:06:21Z")

</div>

Its seems that Mongrel is easier to set up and configure. Out of  
interest how does Mongrel compare to SCGI, in terms of speed?

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [November 2, 2007, 3:26pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/6 "2007-11-02T15:26:39Z")

</div>

Sorry That was in response to Fish Man,

“Its seems that Mongrel is easier to set up and configure. Out of  
interest how does Mongrel compare to SCGI, in terms of speed?”

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [November 2, 2007, 3:20pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/7 "2007-11-02T15:20:14Z")

</div>

I have not been able to test the new Mongrel much but as of yet I feel  
that a mongrel cluster running behind any reverse proxy runs faster  
than using SCGI.  
It is also much easier to setup.

-Ron

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [November 2, 2007, 4:54pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/8 "2007-11-02T16:54:51Z")

</div>

Fish Man wrote:

> Its seems that Mongrel is easier to set up and configure. Out of  
> interest how does Mongrel compare to SCGI, in terms of speed?

A cluster of SCGI listeners is the same speed as a cluster of Mongrel  
listeners, the difference is not statistically significant. I don’t  
think it is any more difficult to set up, but there is more  
documentation about how to set up a mongrel cluster. If you read the  
README that comes with ruby-style, you’ll see setting up a cluster of  
SCGI listeners is quite simple, but that’s the only place you’ll find  
documentation.

Jeremy

---

<div class="post-metadata">

**Author:** ![fishman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e9bcb4/32.png) [@fishman2001](https://www.ruby-forum.com/u/fishman2001)\
**Post date:** [November 2, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/scgi-rails-and-apache/118304/9 "2007-11-02T17:15:37Z")

</div>

One thing to note is RAM usage. Each mongrel instance requires about  
30-40MB ram because it spwns its own ruby process. If you are running  
on a VPS or something similar you may need to rethink your deployment  
strategy.

-Ron
