Memory use: WEBrick vs Apache

Hello,

From purely a memory consumption standpoint, is it generally more
efficient to run a simple Rails app using WEBrick alongside a separate
apache installation or to run Rails under FCGI and use Apache to bridge
to the Web?

I have looked through lots of docs and old forum posts. Most seem to
center on just getting Apache+Rails running, or on speed.

I am really not concerned about my Rails performance, as my app runs
sufficiently fast, is very simple and will not be used by more than a
handful of people (not at all at one moment).

I do care about memory, though, because I have to fit RoR,
Apache+mod_perl and the mysql server inside 160MB of RAM. I just slimmed
mysql way down in terms of memory use, so I think I will be OK to keep
using WEBrick. WEBrick+Rails is roughly 25MB of memory use, excluding
shared libs. If I can reduce that by putting it inside an FCGI process,
great, then I can give some memory back to mysql for db caching.

If not, no big deal.

Thoughts? Thanks for any help.

In my experience, WEBrick leaks memory at a pretty fair rate - if
you’re going to use WEBrick for anything other than development, I’d
plan to bounce the process reasonably often.

I should add that I haven’t used WEBrick for a while, so it may have
improved in this area since I last checked it.

Regards

Dave M.

Thanks Dave, I’ll keep an eye on WEBrick. I hadn’t noticed leakage but
can’t rule it out, either, since I have been restarting the server
pretty often for various reasons. I assume it lives inside the ruby
process.

On Feb 18, 2006, at 5:01 PM, David M. wrote:

center on just getting Apache+Rails running, or on speed.
using WEBrick. WEBrick+Rails is roughly 25MB of memory use, excluding
I should add that I haven’t used WEBrick for a while, so it may have
improved in this area since I last checked it.

If there is leakage occurring it comes from Rails’ use of WEBrick not
WEBrick itself. I see stable process sizes from the image server I’m
using in 43 Things.

$ ps -auxwwwp 53011
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
www 53011 3.8 0.5 24856 10476 ?? S 12:45PM 70:32.68 /usr/
local/bin/ruby18 -w /usr/local/bin/image_httpd
$ date
Sat Feb 18 23:12:59 PST 2006

I don’t perform access logging, but I estimate this WEBrick instance
has handled at least 300k hits.


Eric H. - [email protected] - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com

Hmm, I was seeing quite significant memory leaks within a couple of
hundred hits. That was on Windows XP, not *nix.

As Eric says, that could be a Rails issue instead of a WEBrick issue,
or it could be that I was on (I think) Ruby 1.8.1 at the time and
things have improved since.

Dave M.

Eric H. wrote:

If there is leakage occurring it comes from Rails’ use of WEBrick not
WEBrick itself. I see stable process sizes from the image server I’m
using in 43 Things.

I ran ‘typo’ on WEBrick for several months, and it seemed pretty stable.

The advantage one might see with fcgi is that, configured properly, it
will ‘go away’ when it’s not in use, whereas WEBrick is always going to
be there…


David N. Welton

Linux, Open Source Consulting