Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unicorn Rails - Takes 100% CPU while starting in production mode

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 ...

like image 624
Krishna Prasad Varma Avatar asked Aug 09 '11 09:08

Krishna Prasad Varma


1 Answers

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.

like image 167
whitequark Avatar answered Oct 14 '22 07:10

whitequark