缓慢的客户端连接会阻止 Mongrel
我的 Rails 应用程序有 Apache + Haproxy + Mongrel 设置。 当我访问特定的服务器页面时,mongrel 需要大约 100 毫秒来处理请求,由于我的家庭连接速度慢,数据传输时间长,我在大约 5 秒内获得该页面。
现在我看到在这 5 秒的数据传输期间, mongrel 不服务任何其他请求。 我很惊讶,因为这意味着 mongrel 正在向客户端提供响应 html,并且在客户端收到它之前被阻止。 提供响应不应该是 Apache 的工作吗?
这给 Mongrel 可以提供的请求数量带来了严重的瓶颈,因为这取决于客户端连接的速度。 有没有办法让 mongrel 生成的 html 由 apache/haproxy 或任何其他 Web 服务器(如 nginx)提供服务?
我想知道其他高流量网站是如何管理它的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数使用 mongrel 的网站都会使用很多它们,因为它们确实会像您遇到的那样被阻止。
您可能会想调查一下乘客,因为现在这是他们的做法。
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.
mongrel 本身是多线程的,但是 Rails 默认情况下一次只能处理一个进程,尽管这可以通过 config.json 进行更改。 如果是 mongrel,请使用 mongrel-cluster。
供参考:乘客还设置了一个应用程序池,但它更易于部署,具有更好的新闻效果,并且现在更受欢迎。
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.