Tweaking Rails to Reduce RAM Usage

Is there a way to tweak rails 1.0 or 1.1-rc1 to use less RAM?

I’m using a VPS (Linux UML) with < 160 MB RAM and would like to explore
ways to make rails run more efficiently under such constraints.

Are there articles/tips about this or do I need to look into this from
scratch?

Rails wrote:

Is there a way to tweak rails 1.0 or 1.1-rc1 to use less RAM?

I’m using a VPS (Linux UML) with < 160 MB RAM and would like to explore
ways to make rails run more efficiently under such constraints.

Are there articles/tips about this or do I need to look into this from
scratch?

Two things I’m aware of:

  1. don’t use more FCGI processes than you need - one or two should be
    fine unless you have many users

  2. don’t load Rails frameworks that you aren’t using: see
    config/environment.rb around line 15:

    Skip frameworks you’re not going to use

    config.frameworks -= [ :action_web_service, :action_mailer ]

Uncomment the second line shown if you are not using ActionWebService or
ActionMailer.

HTH

Justin

Another option is to recompile your binaries with -Os if your compiler
supports the flag (only very old versions of gcc don’t use this flag
properly). This does provide a sizable decrease in binary size and thus
the
code size in memory.

As well as the memory Rails uses, you should look at the memory it’s
supporting processes such as the spawner / reaper are using. I have a
128Mb Xen based VPS and switched to using runit for process
supervision with the help of the capistrano-runit-tasks library I wrote.

I’ve just replied to Roberto S. in the ANN: capistrano-runit-
tasks 0.2.0 thread with more details so have a look at that.

Cheers,

Chris