Swap problems with mongrel

I have a Ubuntu linux setup with 512MB of RAM. We haven’t launched our
site yet, so we only have about 100 unique visitors per day. Our site
is very dynamic in nature (i.e. database driven). We are running Rails
behind Apache 2.2 with 4 instances of Mongrel. However, we keep running
out of memory and are swapping way too much.

My problem is very similar to what’s described here:
http://izumi.plan99.net/blog/?p=19

Has anyone here run into this? I’m wondering what’s a good
solution/workaround (e.g. JRuby + Java app server instead of Mongrel,
the fork() and ActiveRecord kluge).

Thanks.

Ben K. wrote:

Has anyone here run into this? I’m wondering what’s a good
solution/workaround (e.g. JRuby + Java app server instead of Mongrel,

JRuby folks should answer that one. My guess is that the relatively
large JVM footprint is probably outweighed by less memory usage per
mongrel instance when you raise the number of mongrel instances above a
limit. You’ll probably have to test your application with JRuby to find
out where the limit is in your case.

You should probably :

  • switch to lighttpd or nginx to save memory, they are both dead simple
    to setup with step by step tutorials only a few keypresses in the Google
    form away.
  • if you witness mongrels memory usage jumping up, do 2 things :
    • use nginx and get seesaw to reload your application when you begin
      to swap. The graceful restart seesaw manages will protect you from angry
      clients while saving memory.
    • while the above solves the symptom, look for the problem : dump your
      database and reload it on your development environment and find the
      actions that make your memory usage jump and fix them if you can.

Lionel

Thanks, Lionel.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs