Unicorn Rails - Takes 100% CPU while starting in p

2019-04-27 22:08发布

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

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

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

1条回答
戒情不戒烟
2楼-- · 2019-04-27 22:37

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.

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.

查看更多
登录 后发表回答