Phusion Passenger Rails不平衡工作人员的请求

时间:2017-07-18 11:31:00

标签: ruby-on-rails nginx passenger

以下是我在服务器上运行乘客状态时的输出

Requests in queue: 0
 * PID: 1821    Sessions: 0       Processed: 2971    Uptime: 15m 11s
   CPU: 14%     Memory  : 416M    Last used: 0s ago
 * PID: 1847    Sessions: 0       Processed: 1066    Uptime: 15m 11s
   CPU: 6%      Memory  : 256M    Last used: 2s ago
 * PID: 1861    Sessions: 0       Processed: 199     Uptime: 15m 11s
   CPU: 1%      Memory  : 238M    Last used: 3s ago
 * PID: 1875    Sessions: 0       Processed: 37      Uptime: 15m 10s
   CPU: 0%      Memory  : 196M    Last used: 15s ago
 * PID: 1900    Sessions: 0       Processed: 7       Uptime: 15m 10s
   CPU: 0%      Memory  : 136M    Last used: 33s ago
 * PID: 1916    Sessions: 0       Processed: 4       Uptime: 15m 10s
   CPU: 0%      Memory  : 126M    Last used: 33s ago
 * PID: 1932    Sessions: 0       Processed: 1       Uptime: 15m 10s
   CPU: 0%      Memory  : 132M    Last used: 14m 44s ago
 * PID: 1946    Sessions: 0       Processed: 0       Uptime: 15m 10s
   CPU: 0%      Memory  : 68M     Last used: 15m 10s ago
 * PID: 1962    Sessions: 0       Processed: 0       Uptime: 15m 9s
   CPU: 0%      Memory  : 53M     Last used: 15m 9s ago
 * PID: 1980    Sessions: 0       Processed: 0       Uptime: 15m 9s
   CPU: 0%      Memory  : 53M     Last used: 15m 9s ago

我们运行的堆栈是Nginx + Passenger + Rails。 我关注的是,文档说乘客必须在自己产生的工作人员之间分配负载,但正如我们从日志中看到的那样,只有前2名工人得到了所有请求,其余的只是空闲。

随着时间的推移,顶级工作人员的内存使用量也会增加。 这是预期的行为吗? 我怎样才能纠正这个问题,能否以任何方式提高绩效?

我的乘客也在下面

  passenger_max_pool_size 20;
  passenger_min_instances 10;
  passenger_max_instances_per_app 0;
  passenger_pre_start <api-endpoint>;
  passenger_pool_idle_time 0;
  passenger_max_request_queue_size 0;

1 个答案:

答案 0 :(得分:1)

愚蠢的我,几分钟前我发表了评论,现在我找到了答案。

摘要:Passenger使用简单的算法尽可能填写最高请求,而不是使用循环法,您的应用程序没有任何问题。

链接解释了大部分内容。

https://www.phusionpassenger.com/library/indepth/ruby/request_load_balancing.html#traffic-may-appear-unbalanced-between-processes