7

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

Krishna Prasad Varma
  • 4,670
  • 5
  • 29
  • 41

1 Answers1

2

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.

Catherine
  • 22,492
  • 3
  • 32
  • 47
  • thank you for the immediate reply . i just love it.. surely i will try with preload_app true . btb i have only 1 worker configured in unicorn.rb conf file. – Krishna Prasad Varma Aug 09 '11 at 11:07
  • 2
    then, that's strange. Amazon instances aren't very powerful, but starting Rails definitely shouldn't take 15 minutes -- heck, 1.5 minutes is enough on my old Pentium III! (by the way, preload_app won't change anything if you only have 1 worker). Try starting it via `strace -f` (without daemonization) and check if some syscalls take much more time than expected. – Catherine Aug 09 '11 at 13:14
  • it i give -D (daemonize) it takes infinite time . but when i run it without -D it works atlease after 5-10 mts. and i leave the terminal for session out .. SAD !!!! – Krishna Prasad Varma Aug 14 '11 at 09:45
  • start with fewer workers you can always add to the worker pool on the fly with __kill -TTIN __ – engineerDave Mar 15 '13 at 18:40
  • 1
    1 thing I observed, If you give wrong database name then every unicorn worker keeps trying to connect database which is not present and in that case it takes 100 % CPU – sagar junnarkar Mar 19 '14 at 12:43