Unicorn Rails - 在生产模式下启动时占用 100% CPU [英] Unicorn Rails - Takes 100% CPU while starting in production mode

查看:68
本文介绍了Unicorn Rails - 在生产模式下启动时占用 100% CPU的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Unicorn_Rails + nginx.它在我的系统(4GB Ram,Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz)的开发模式和生产模式下运行良好我可以在本地系统中启动 10 个工人,但在任何情况下都无法在生产中启动 2 个以上的工人有时它有效,但需要等待 15-20 米启动unicorn_rails时一直占用99.6%的CPU

We are using Unicorn_Rails + nginx. It works well in development mode and production mode in my system ( 4GB Ram , Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz) i am able to start 10 workers in local system but unable to start more than 2 in any case in production sometimes it works but need to wait for 15- 20 mts It takes 99.6% CPU all the time while starting unicorn_rails

英特尔(R) 至强(R) CPU E5507 @ 2.27GHz但它挂在亚马逊( m1.small 实例)1.73 GB 内存

Intel(R) Xeon(R) CPU E5507 @ 2.27GHz but it hangs in amazon ( m1.small instance ) 1.73 GB RAM

我发现没有人谈论在任何地方使用 unicorn_rails 的缓慢启动......

i find no one talking about a slow startup using unicorn_rails anywhere ...

推荐答案

Rails 启动受 CPU 限制,它(几乎)始终使用 100% 的 CPU.看起来您试图在该实例上施加的负载太大;每个 CPU 核心只需要 1 个工作线程,而 m1.small 只有一个.

Rails startup is CPU-bound, it will (almost) always use 100% of CPU all the time. Looks like the load you are trying to put on that instance is too large; you only need 1 worker per CPU core, and m1.small has just one.

当您尝试启动 10 个 worker 时,它们共享 CPU 和 I/O,并且大量 I/O 请求总是会减慢子系统的速度.您可以在 config/unicorn.rb 中添加 preload_app true 子句;这应该会降低启动时间,但在这样的实例上您确实不需要 10 个工作人员.

When you try to start 10 workers, they're sharing both CPU and I/O, and a lot of I/O requests always slows the subsystem down. You can add preload_app true clause in your config/unicorn.rb; this should lower the startup time, but you really do not need 10 workers on such an instance.

这篇关于Unicorn Rails - 在生产模式下启动时占用 100% CPU的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆