views:

127

answers:

2

I have a Apache + Haproxy + Mongrel setup for my rails application. When I hit a particular server page, mongrel takes around 100ms to process the request and I get the page in around 5 secs due to data transmission time on my slow home connection.

Now I see that during these 5 secs of data transmission, mongrel does not serve any other request. I am surprised as that means mongrel is serving the response html to the client and is blocked till the client receives it. Shouldn't serving response be the job of Apache?

This puts serious bottleneck in the no of requests Mongrel can serve as that would depend on the speed of the client connection. Is there any way that html generated by mongrel is served by apache/haproxy or any other web server like nginx?
I wonder how the other high traffic sites are managing it?

+1  A: 

Most sites that use mongrel use lots of them as they do block like you are experiencing.

You'll probably want to look into passenger instead as it is they way to go these days.

srboisvert
A: 

mongrel itself is multi-threaded, but rails can process only one process at a time by default, although this can be changed by config. In case of mongrel, use mongrel-cluster.

FYI passenger also sets up a pool of applications but it is nicer to deploy, has better press and is more popular right now.

deepak
I am not sure if I understood "rails can process only one process at a time". I know that 1 instance of mongrel would only serve 1 rails request. So for concurrent processing of 5 requests, I need to run 5 mongrel instances. Same for passenger, increase the no of threads.
Sanjay
sorry meant to say "rails can process only one request at a time" - not "only one process"
deepak