Unicorn can't allocate memory

I need your help!

I deployed the Rails application on Ubuntu 12.04 using Nginx, MySQL, Solr, and Unicorn.

Each service mentioned is launched, not a unicorn, which reads as follows:

I, [2013-02-11T16: 10: 20.187989 # 27547] INFO -: Updating the list of gems I, [2013-02-11TT16: 10: 52.159198 # 27547] INFO -: canceling existing socket = / var / www / staging /shared/unicorn.sock I, [2013-02-11T16: 10: 52.159488 # 27547] INFO -: listening addr = / var / www / staging / shared / unicorn.sock fd = 12 E, [2013-02-11T16 : 10: 52.161513 # 27547] ERROR -: Unable to allocate memory - fork (2) (Errno :: ENOMEM) /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib /unicorn/http_server.rb:496:in fork' /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/lib/unicorn/http_server.rb:496:in spawn_missing_workers' / var / www / staging / shared / gems / ruby ​​/ 1.9.1 / gems / unicorn-4.5.0 / lib / unicorn / http_server.rb: 142: in start' /var/www/staging/shared/gems/ruby/1.9.1/gems/unicorn-4.5.0/bin/unicorn_rails:209:in "/ var / www / staging / shared / gems / ruby ​​/ 1.9.1 / bin / unicorn_rails: 23: in load' /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:in load' /var/www/staging/shared/gems/ruby/1.9.1/bin/unicorn_rails:23:in '

VDS has 1.5 GB of RAM and is enough for a unicorn:

 cat /proc/meminfo 
 MemTotal: 1585152 kB MemFree: 989580 kB Cached: 425296 kB Active: 348504 kB Inactive: 175356 kB Active(anon): 98488 kB Inactive(anon): 76 kB Active(file): 250016 kB Inactive(file): 175280 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 204800 kB SwapFree: 204800 kB Dirty: 12 kB Writeback: 0 kB AnonPages: 98564 kB Shmem: 3604 kB Slab: 71680 kB SReclaimable: 66144 kB SUnreclaim: 5536 kB 

I have unicorn_rails v4.5.0

The unicorn starts with the following command:

bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D

What am I doing wrong here?


Hmm, I remembered that I had the following strange error before:

 failed: "rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'ruby-1.9.3-p327' -c 'cd /var/www/staging/current && bundle exec unicorn_rails -c /var/www/staging/current/config/unicorn.rb -E production -D'" 

Perhaps this has something to do with memory issues ...

+6
source share
1 answer

It seems that the error occurs when forking new processes. You may need to reduce the number of workers in the config / unicorn.rb file. Each worker is a process, and each process loads the application environment into RAM.

+2
source

All Articles