# Tweaking Rails to Reduce RAM Usage

**URL:** <https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928>\
**Category:** Rails\
**Created:** [March 24, 2006, 11:36pm UTC](https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928 "2006-03-24T23:36:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 24, 2006, 11:36pm UTC](https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928/1 "2006-03-24T23:36:55Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 25, 2006, 3:56am UTC](https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928/2 "2006-03-25T03:56:47Z")

</div>

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:

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

HTH

Justin

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 25, 2006, 7:54am UTC](https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928/3 "2006-03-25T07:54:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 25, 2006, 1:58pm UTC](https://www.ruby-forum.com/t/tweaking-rails-to-reduce-ram-usage/86928/4 "2006-03-25T13:58:21Z")

</div>

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
