views:

109

answers:

2

My Ruby on Rails application is consuming around 129 MB of memory.. is this normal?

I have around 3,000 unique visitors a day, i have no complex queries...

My users table has about 18k rows.

A: 

I've seen rails applications go as high as 500mb. I'm pretty sure larger ones exist. Unique visitors and database queries are not the cause of memory usage. It's the expensive and large in-memory computations in Ruby.

Try AB testing some of those methods and see how high your memory usage gets. That might solve some memory issues.

porkeypop
+1  A: 

129MB doesn't seem too excessive to me, what I find more important is does that number grow over time?

if it does the problem is probably how much of your dataset you are loading into memory on a request

check out: http://www.engineyard.com/blog/2009/thats-not-a-memory-leak-its-bloat/

in breif: Instantiating too many active record objects is a place where rails app's memory footprint really grows.

If in a request, you were to iterate over all 18k users for some reason, and worse, iterate over all of their posts (or whatever associations you have), you'd be instantiating a ton of objects, which (should) get cleared after the request, but ruby doesn't give the memory back to the system after it has been alocated.

Dennis Collective
Thanks for your response Dennis, i have one question though.. how many is too many active record objects I'dont iterate over all 18k users, but i do update 64 active record objects (one by one) when the user saves a specific form... should i update in a single query then? Another thing is that my rails app keeps crashing... it says: "[FATAL] failed to allocate memory"
Will
64 update queries per save is excessive
Omar Qureshi
It depends how big the objects are, but you should be able to deal with many thousands of objects.when you do the update, are you doing ":include =>"'s on the objects?trying to find a more efficient way to do it, rather than 64 updates of 64 other objects seems like it would be smart.doing what specifically makes your app crash?how much memory does your server have? are you out of it? how big is the app when it starts/right before it dies? in googling that fatal error.once again, these guys are smarter than me.http://www.engineyard.com/blog/2009/thats-not-a-memory-leak-its-bloat/
Dennis Collective