サーバのメモリ不足

赖洪礼的 blog » Saving memory in Ruby on Rails with fork() and copy-on-write

これを読んでみると,FastCgiでもMogrelでも,1つのRails Processに20MB〜30MBのメモリが食われるらしい.で,筆者は,My web server has “only” 1 GB of RAM.だとおっしゃる.なるほど僕のサーバがSwapしまくるわけだ...

今は,Mogrelで2アプリx3プロセス,計6プロセス起動させているので,最低でも120MBは常にメモリを消費してることになる.サーバのメモリは,256MBしか積んでないのに,これは厳しすぎる.

で,調べてみたらその通りだった.6プロセスで140MB消費してる.

mogrel cluster停止時
             total       used       free     shared    buffers     cached
Mem:        255300     101132     154168          0       1516      25976
-/+ buffers/cache:      73640     181660
Swap:       524280     116468     407812
mogrel cluster起動時
             total       used       free     shared    buffers     cached
Mem:        255300     240888      14412          0       1620      27612
-/+ buffers/cache:     211656      43644
Swap:       524280      82744     441536

古いVAIOなのでメモリは,Rambus DRAM RIMM,新品で買うと512MBで36000円!!DIMM SDRAM のなんと20倍もする.ありえない.中古を探すか,PC買った方が安いな.