Search code examples
rubymemory-managementgarbage-collectionruby-enterprise-edition

Increased Memory Size after converting to Ruby Enterprise 1.8.7


When upgrading from Ruby 1.8.6 to Ruby Enterprise 1.8.7 p334, the memory size has nearly doubled. This has occurred in every one of the five Fedora 8 servers we upgraded. We run Rails 1.2.6 with Passenger 3.0.4.

Munin gets the memory size for every process by summing the vsz and rsz columns from $ ps axo pid,comm,pmem,vsz,rsz. (The virtual memory size and resident memory size both increase the same amount)

I realize that these columns generally overstate the amount of memory actually used by the processes, but if this was used to measure 1.8.6 and then 1.8.7 REE, they should be equally bloated, and therefore still comparable.

In addition, the committed memory for the machine (as listed in /proc/memstat) is now regularly overcommitting, which is new. The amount committed memory has increased significantly, and it looks like we're now into swap space.

We have not yet tuned the garbage collection, but I can't see how that would affect the overall memory footprint.

I have turned on the GC.copy_on_write_friendly variable as recommended by the Phusion FAQ.

What is the explanation for this 100% increase in memory usage and how can I fix it? Any ideas on how to fix, or even better monitor/debug, are appreciated.

Thanks.

---UPDATE

In order to check performance, I have decreased the number of running instances (PassengerMaxPoolSize) from 12 to 10 on one server. On another, I have raised the PassengerPoolIdleTime to 15 minutes. I have a third that is being used as a control.

I'm considering putting a non-enterprise version 1.8.7p334 on a server to see if it's 1.8.7 or the Enterprise Edition.

Anyone else have any experience with this type of issue?

Looking at the individual Rails processes, they are about 120MB per process in 1.8.6, and 175MB/process in REE 1.8.7, as stated by passenger-memory-stats.

---UPDATE 2

I put MRI 1.8.7 on a server for comparison to REE 1.8.7. The results were worse, including higher memory resident size number and passenger-memory-stats. Of course, swapping started.

This is leading me to believe that 1.8.7 simply has a larger footprint than 1.8.6.

---UPDATE 3

I put MRI 1.8.7 on a server, it was much worse that MRI 1.8.6 in terms of memory usage, so I immediately went back to MRI 1.86.

I've run an average of Rails process size, as listed by passenger-memory-stats. The REE 1.8.7 processes were 73 MB larger, which seems rather large.

This means that I need to have significantly less processes running to fit in the same memory footprint.

Will see how they perform with fewer processes. I'm also starting the GC tuning.

---UPDATE 4

Seems Ruby 1.8.7 does not support Rails 1.2.6. The first officially supported version of 1.8.7 is Rails 2.1. We'll know after the upgrade if that's the root of the problem.


Solution

  • You went from a 32-bit version of Ruby to a 64-bit version of Ruby. This doubles the size of pointers, of which there are many in the runtime.