# Managing number of dispatch.fcgi processes?

**URL:** <https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743>\
**Category:** Rails\
**Created:** [March 4, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743 "2006-03-04T20:28:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [March 4, 2006, 8:28pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743/1 "2006-03-04T20:28:25Z")

</div>

I have a problem where when I try and access my site a dispatch.fcgi  
process is started but then exits right after the page has loaded.  
Requireing it to start all over agin the next time a request is made.  
I’ve read about people using two or more FCGI processes to help with the  
request load but how do people do this?

Firstly, how do you make a FCGI process persistant? I’m not sure why  
mine is exiting, no errors reported in the logs.

Secondly, if you wanted to run 2 or more concurrent FCGI processes how  
would you go about setting that up?

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [March 4, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743/2 "2006-03-04T20:49:53Z")

</div>

On March 4, 2006 12:28, Todd S. wrote:

> would you go about setting that up?  
> Depends on the web server you’re using. For instance, you can set  
> Apache2 and  
> mod\_fcgi to use 4 of persistent fcgi processes with a configuration like

FastCgiServer /abs/path/to/application/public/dispatch.fcgi   
-idle-timeout 120   
-initial-env PERL\_SIGNALS=unsafe   
-initial-env RAILS\_ENV=production   
-processes 4  
You can also set it to dynamically manage its fcgi processes.

For lighttpd you can set min-procs and max-procs in your fcgi  
configuration.  
Look at the documentation here for more details:  
[http://www.lighttpd.net/documentation/fastcgi.html](http://www.lighttpd.net/documentation/fastcgi.html)

For other web servers check the relevant documentation. Hope that  
helps.

Luca

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [March 4, 2006, 10:00pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743/3 "2006-03-04T22:00:46Z")

</div>

Well, I’m on a shared host running apache so I’m not sure how much  
control I have over the configuration. They (dreamhost) and others  
claim that rails works great there but I’ve not seen it work yet.

I do get these errors in my http error log…

Couldn’t write to 4: starting  
TypeError: can’t convert Fixnum into String  
Couldn’t write to 4: terminated gracefully  
TypeError: can’t convert Fixnum into String

I’m not sure if this is the cause of the problem or not.

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [March 4, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743/4 "2006-03-04T22:34:27Z")

</div>

> Couldn’t write to 4: starting  
> TypeError: can’t convert Fixnum into String  
> Couldn’t write to 4: terminated gracefully  
> TypeError: can’t convert Fixnum into String

These erros came from having…  
RailsFCGIHandler.process! 4

in the dispatch.fcgi script as opposed to just

```
RailsFCGIHandler.process!

```

but that didn’t make the process persistant or speed up load time at  
all.

---

<div class="post-metadata">

**Author:** ![sporkyy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c89c15/32.png) [@sporkyy](https://www.ruby-forum.com/u/sporkyy)\
**Post date:** [March 4, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/managing-number-of-dispatch-fcgi-processes/76743/5 "2006-03-04T23:10:03Z")

</div>

Okay, I think I got it…

in my .htaccess file I had

AddHandler fastcgi-script .fcgi  
AddHandler cgi-script .fcgi

if I change it to

AddHandler fastcgi-script .fcgi

# AddHandler cgi-script .fcgi

then things work. Wow.
