Phusion Passenger Not always NonBlocking with Rails?
How does Passenger decide when to fork a new process, and can I configure in any meaningful way how many proccesses it should handle (other than "smart" and "conservative" flags in the configuration?) Alternatively, is there any way to debug why a rails app running under Phusion would suddenly freeze up?
Background:
I'm using Phusion Passenger with the Apache2 server, and for the most part, things are doing fine. I'm less concerned about load, and more concerned about blocking: regular mongrel will tie up the entire app if it hits a long controller method (say, a method that sleeps for ten seconds), and no other web page can be served until the method has completed. With Passenger, I can hit the same method, and still open up a new browswer and hit faster loading pages of the same app with no problem.
SOMETIMES.
And that "sometimes" is a problem. If a method takes long enough (in my case, does an external network call that never comes back), the entire application will once again hang, even with all the spiffy thread forking, or whatever..
My understanding is that the way Passenger works is that it 开发者_JAVA技巧sort of forks off entire new instances of rails every time it needs to, usually in the context of too many people connecting at once.
It DOES seem to work with long methods, though...but I can't see any references to how or why (or more importantly, how to tweak or configure this proccess). Or even how to figure out what the issue might be (Do I need to let Phusion fork off MORE threads, does it just not work with long methods over a certain length of time?)
Whenever a request comes in Phusion Passenger decides which process to forward the request to and marks that process as busy. Once that process is done handling the request it is marked as non-busy.
If all existing processes are marked busy then Phusion Passenger spawns a new process, unless the MaxPoolSize limit is reached, in which case it'll wait until a process becomes non-busy.
What exactly do you want to customize? What exactly do you mean by "freeze up"? Are you perhaps referring to the "slow Mongrel queue problem"? Phusion Passenger has a feature called Global Queuing which solves that problem. The problem as well as its solution is documented extensively in the Phusion Passenger manual and since version 3.0.0 beta this option is turned on by default.
精彩评论