Thursday, February 5, 2009

Mongrel 1.1.5 on ubuntu 8.04 and rail 2.1.1

We host our production environment using Ubuntu 7.04 and mongrel 1.1.4 for our Rails applications. We setup our test server with Ubuntu 8.04 and mongrel 1.1.5 and noticed the server was crashing all the time. As I started to dig into this, I noticed that mongrel was chewing up all the memory with haste. We then turned off all the rails apps and just let mongrel go for a couple of days. It ate up all the memory until it killed our VPS. If we shutdown mongrel all the memory comes right back. Just to repeat, this application has no usage. The ports are not even open. Its just a rails stack with Mongrel running and its eating all the memory. So when the guys online tell you its not mongrel, don't believe it.


So I started working on some upgrades to make sure we were at the latest versions.

I updated Ubuntu first by doing a simple:
sudo apt-get update
sudo apt-get upgrade

We did have several packages that needed to be upgraded. This ended in ruby being at version:
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]

Then I needed to upgrade rubygems from 1.2.0 to 1.3.1
I couldn't use
gem update --system
I used these instead:
sudo gem install rubygems-update

sudo update_rubygems


Mongrel 1.1.5 is the latest gem I could see but I did a gem install mongrel just for fun. It recompiled and installed 1.1.5

I then did:
gem install rails
That brought me to rails version 2.2.2.
I next did a gem update for the rest of the gems. I wasn't really interested in doing all of those one at a time. There were quite a few. They shouldn't matter, because the application is not getting used at all. But if you want to see here is what was updated:
Gems updated: RedCloth, ZenTest, net-ssh, capistrano, columnize, fastercsv, highline, rubyforge, hoe, libxml-ruby, memcache-client, net-scp, net-sftp, net-ssh-gateway, packet, rmagick, ruby-debug-base, ruby-debug


To start my simple scenario I started two mongrels and let them sit. After mongrel was started the system had 102,260K free with both mongrels taking 9.4% of the memory. Now we wait.
At 1 hr of no usage we are down to 100,028K of memory. The question is when will it stop? The answer that is usually prescribed is to use Monit and kill the mongrels and restart them. No problem. I prefer to not think restarting a process is a solution to the problem, while its a fix, its not ideal.

Update: At the end of day 1 memory is now at 31456K. Now killing process.

My answer for right now is to switch to mod_rails. mod_rails has been shown in performance tests to beat 10 mongrels. I'll let you know the process to get rid of Mongrel. I understand that 37 Signals has now switched to mod_rails as well.

Let me know your experience with either of these tools.

No comments:

Post a Comment