Ruby-on-rails 网站负载过重 + ROR
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20537185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The website is under heavy load + ROR
提问by Rahul Kumar
We are running a website with ROR on CentOS 6 with 2 web server and 1 database server. Some times it shows message "The website is under heavy load"... Can some plese help you what to check here.
我们正在 CentOS 6 上运行一个带有 ROR 的网站,带有 2 个 Web 服务器和 1 个数据库服务器。有时它会显示消息“网站负载过重”...请帮助您在这里检查什么。
We are using Passenger 4.0.21 with Ruby 1.8.7 and Apache 2.2.15. Web server is running with the default settings.
我们将Passenger 4.0.21 与Ruby 1.8.7 和Apache 2.2.15 一起使用。Web 服务器以默认设置运行。
Below is some output of passenger-status:
以下是乘客状态的一些输出:
# passenger-status
# 乘客状态
Version : 4.0.21
Date : Thu Dec 12 02:02:44 -0500 2013
Instance: 20126
----------- General information -----------
Max pool size : 6
Processes : 6
Requests in top-level queue : 0
----------- Application groups -----------
/home/web/html#default:
App root: /home/web/html
Requests in queue: 100
* PID: 20290 Sessions: 1 Processed: 53 Uptime: 24h 3m 5s
CPU: 0% Memory : 634M Last used: 23h 16m 8
* PID: 22657 Sessions: 1 Processed: 37 Uptime: 23h 15m 55s
CPU: 0% Memory : 609M Last used: 22h 44m
* PID: 29147 Sessions: 1 Processed: 146 Uptime: 20h 47m 48s
CPU: 0% Memory : 976M Last used: 18h 20m
* PID: 22216 Sessions: 1 Processed: 26 Uptime: 10h 3m 19s
CPU: 0% Memory : 538M Last used: 9h 44m 4
* PID: 23306 Sessions: 1 Processed: 75 Uptime: 9h 43m 22s
CPU: 0% Memory : 483M Last used: 8h 44m 4
* PID: 25626 Sessions: 1 Processed: 115 Uptime: 8h 46m 42s
CPU: 0% Memory : 540M Last used: 7h 59m 5
回答by cantonic
You have too many requests in queue. Since version 4.0.15 there is a limit which is 100 by default. Here is a short excerpt from http://blog.phusion.nl/2013/09/06/phusion-passenger-4-0-16-released/which says:
队列中的请求过多。从 4.0.15 版本开始,默认限制为 100。这是http://blog.phusion.nl/2013/09/06/phusion-passenger-4-0-16-released/的简短摘录,其中说:
Phusion Passenger now displays an error message to clients if too many requests are queued up, instead of letting them wait. This much improves quality of service. By default, "too many" is 100. You may customize this with
PassengerMaxRequestQueueSize(Apache) orpassenger_max_request_queue_size(Nginx).
如果排队的请求过多,Phusion 乘客现在会向客户端显示错误消息,而不是让他们等待。这大大提高了服务质量。默认情况下,"too many" 是 100。您可以使用
PassengerMaxRequestQueueSize(Apache) 或passenger_max_request_queue_size(Nginx) 对其进行自定义。
Have a look at the user guide about this: http://www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerMaxRequestQueueSize
看看关于这个的用户指南:http: //www.modrails.com/documentation/Users%20guide%20Apache.html#PassengerMaxRequestQueueSize
You could try increasing it or setting it to 0in order to disable it.
您可以尝试增加它或将其设置0为以禁用它。
EDIT
编辑
You should also check your logs to see whether there are requests which take too long. Maybe you have some processes in your code that take too long. I prefer using NewRelic for monitoring those things.
您还应该检查您的日志以查看是否有需要太长时间的请求。也许您的代码中有一些进程花费的时间太长。我更喜欢使用 NewRelic 来监控这些东西。

