Reduce Mongrel Rails Memory Footprint & Increase performance?
Asked Answered
F

4

6

My rails sites run Mongrel, I am having a problem with the amount of memory being used. My ruby-bin processes are using up about 66 MB of resident memory. How can I reduce the amount of memory used by rails?

It is not very economical to have many rails servers running on a single machine if they are eating memory at this rate. My php5 fcgi processes sit at between 15-25 MB.

I'm fairly unfamiliar with RoR, would using JRuby help? Any comments helpful in reducing memory footprint and increasing performance are more than welcome.

Frankiefrankincense answered 13/5, 2009 at 19:45 Comment(0)
L
7

You might look at Phusion Passenger and Ruby Enterprise Edition, which is the de facto standard setup for Rails apps these days. One of its aims is cutting memory use. It's also simpler than having a bunch of Mongrels.

Lipsey answered 13/5, 2009 at 19:51 Comment(1)
+1 I second the REE recommendation, as it include the MBARI patches making it consume much less memory. That or 1.9 also uses less. Also make sure you're running a 32 bit OS where possible.Brownstone
O
3

If you are not tied to apache for something else, i would also try nginx with Phusion Passenger. If you're concerned about memory usage, you should see a smaller footprint from nginx than apache, and the lastest version of Passenger will download, compile and install nginx for you with minimal headaches.

Outstrip answered 13/5, 2009 at 20:59 Comment(0)
G
3

You can also replace your mongrel process with Thin which is more efficient and has recently been patched in its Garbage Collection (thru eventmachine), to make it even better.

We use thin cluster behind nginx frontends with fine results.

Guise answered 14/5, 2009 at 11:48 Comment(0)
G
1

I wouldn't go so far as to say Passenger is the de facto standard, but it's gaining a lot of traction. We just switched to Nginx+Passenger, and our ruby app (i.e. Mongrels vs. Passenger) memory footprint dropped from about 450MB to 295MB. It can drop less, as Passenger will kill off procs if they idle (this is configurable), but of course if you're getting traffic and it's using all of the instances you have it configured to, then they'll use up memory accordingly.

Note, that we are not using Ruby Enterprise Edition in our config yet (mainly because it's not yet available at Engine Yard), but we still are seeing a smaller memory footprint. Memory was the initial top reason we made the switch, but there are other benefits, such as faster and easier configuration for scaling up or down, and so on.

Gasaway answered 14/5, 2009 at 7:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.