# Memory use: WEBrick vs Apache

**URL:** <https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976>\
**Category:** Rails\
**Created:** [February 19, 2006, 1:09am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976 "2006-02-19T01:09:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 1:09am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/1 "2006-02-19T01:09:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 2:03am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/2 "2006-02-19T02:03:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 3:14am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/3 "2006-02-19T03:14:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 8:19am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/4 "2006-02-19T08:19:11Z")

</div>

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. - removed\_email\_address@domain.invalid - [http://segment7.net](http://segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)

---

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 8:52am UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/5 "2006-02-19T08:52:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ryantate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e56c9b/32.png) [@ryantate](https://www.ruby-forum.com/u/ryantate)\
**Post date:** [February 19, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/memory-use-webrick-vs-apache/53976/6 "2006-02-19T14:49:48Z")

</div>

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

- [David N. Welton](http://www.dedasys.com/davidw/)

Linux, Open Source Consulting

- [http://www.dedasys.com/](http://www.dedasys.com/)
