FastCGI and threads

G

George Moschovitis

Somewhat related to the earlier post:

Some time ago another ruby user tried UNSUCCESSFULLY the following code:

FCGI.each do |fcgi|
Thread.new(fcgi) { |f|
f.out.print "Content-type: text/html\r\n\r\n"
f.out.print f.out.type, "<br>\n"
...
}
end

matz replied:

fcgi is not thread-safe. Unlike other IO facilities, it does not try to
avoid IO blocking. I'll make fcgi thread-safe soon (or I hope someone
voluneer to update it).

Is fcgi thread safe now ? Can code like this work with fcgi?

thanks in advance,

George Moschovitis
 
A

Ara.T.Howard

Somewhat related to the earlier post:

Some time ago another ruby user tried UNSUCCESSFULLY the following code:

FCGI.each do |fcgi|
Thread.new(fcgi) { |f|
f.out.print "Content-type: text/html\r\n\r\n"
f.out.print f.out.type, "<br>\n"
...
}
end

matz replied:

fcgi is not thread-safe. Unlike other IO facilities, it does not try to
avoid IO blocking. I'll make fcgi thread-safe soon (or I hope someone
voluneer to update it).

Is fcgi thread safe now ? Can code like this work with fcgi?

thanks in advance,

George Moschovitis

what will this buy you? fastcgi is process based from apache's point of view
- it's not going to send another request until it gets all the output from the
first one so this approach buys you nothing. in fact, it should slow a
fastcgi process down since it now has the cost of creating a thread for every
request. also, if the load is very high for a particular fcgi program
mod_fastcgi will start another one to manage the load (process pools). in
short, i think this will only complicate matters for no improvement.

regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 
C

Carl Youngblood

True that in this particular case threads aren't necessary, but it
would still be nice to know if fcgi is thread-safe for other
purposes, such as that automatic process reloader that you and I were
talking about a while back.

Somewhat related to the earlier post:

Some time ago another ruby user tried UNSUCCESSFULLY the following code:

FCGI.each do |fcgi|
Thread.new(fcgi) { |f|
f.out.print "Content-type: text/html\r\n\r\n"
f.out.print f.out.type, "<br>\n"
...
}
end

matz replied:

fcgi is not thread-safe. Unlike other IO facilities, it does not try to
avoid IO blocking. I'll make fcgi thread-safe soon (or I hope someone
voluneer to update it).

Is fcgi thread safe now ? Can code like this work with fcgi?

thanks in advance,

George Moschovitis

what will this buy you? fastcgi is process based from apache's point of view
- it's not going to send another request until it gets all the output from the
first one so this approach buys you nothing. in fact, it should slow a
fastcgi process down since it now has the cost of creating a thread for every
request. also, if the load is very high for a particular fcgi program
mod_fastcgi will start another one to manage the load (process pools). in
short, i think this will only complicate matters for no improvement.

regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 
A

Ara.T.Howard

True that in this particular case threads aren't necessary, but it
would still be nice to know if fcgi is thread-safe for other
purposes, such as that automatic process reloader that you and I were
talking about a while back.

oh yeah - non-output related thread would indeed be nice. although i must add
that even that code is just as easily implemented w/o threads: just check
after each request is handled and exit if the source is updated (or on some
other condition).

in the end, the route i took was to test via a link

page.cgi -> page.fcgi

since this will be loaded everytime, and simply reload the fcgi when i was
satisfied. ended up being just as easy.

you still doing much fcgi work then? i haven't been able to do anything web
related lately... ;-(

-a
Somewhat related to the earlier post:

Some time ago another ruby user tried UNSUCCESSFULLY the following code:

FCGI.each do |fcgi|
Thread.new(fcgi) { |f|
f.out.print "Content-type: text/html\r\n\r\n"
f.out.print f.out.type, "<br>\n"
...
}
end

matz replied:

fcgi is not thread-safe. Unlike other IO facilities, it does not try to
avoid IO blocking. I'll make fcgi thread-safe soon (or I hope someone
voluneer to update it).

Is fcgi thread safe now ? Can code like this work with fcgi?

thanks in advance,

George Moschovitis

what will this buy you? fastcgi is process based from apache's point of view
- it's not going to send another request until it gets all the output from the
first one so this approach buys you nothing. in fact, it should slow a
fastcgi process down since it now has the cost of creating a thread for every
request. also, if the load is very high for a particular fcgi program
mod_fastcgi will start another one to manage the load (process pools). in
short, i think this will only complicate matters for no improvement.

regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 
G

George Moschovitis

what will this buy you? fastcgi is process based from apache's point of view
....
short, i think this will only complicate matters for no improvement.

hmm thanks for this info I was not aware of this limitation.

-g.
 
A

Ara.T.Howard

hmm thanks for this info I was not aware of this limitation.

WRT io i don't think it acutally ends up being much of a limitation:

[ahoward@www ahoward]$ ab -n1024 http://127.0.0.1/env.fcgi|grep Requests
Requests per second: 221.96 [#/sec] (mean)

however - not being able to do something other than produce io in a thread
could be viewed as a limitation.

regards.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,406
Latest member
ElizabetMo

Latest Threads

Top