# Swap problems with mongrel

**URL:** <https://www.ruby-forum.com/t/swap-problems-with-mongrel/122699>\
**Category:** Rails\
**Created:** [December 10, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/swap-problems-with-mongrel/122699 "2007-12-10T23:04:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thabenksta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@thabenksta](https://www.ruby-forum.com/u/thabenksta)\
**Post date:** [December 10, 2007, 11:04pm UTC](https://www.ruby-forum.com/t/swap-problems-with-mongrel/122699/1 "2007-12-10T23:04:59Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![thabenksta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@thabenksta](https://www.ruby-forum.com/u/thabenksta)\
**Post date:** [December 12, 2007, 10:33pm UTC](https://www.ruby-forum.com/t/swap-problems-with-mongrel/122699/2 "2007-12-12T22:33:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![thabenksta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/97f17d/32.png) [@thabenksta](https://www.ruby-forum.com/u/thabenksta)\
**Post date:** [December 12, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/swap-problems-with-mongrel/122699/3 "2007-12-12T23:43:09Z")

</div>

Thanks, Lionel.
