Hacker News new | ask | show | jobs
by furiouslol 6454 days ago
Here is my experience. I used Rails for one project of mine that requires processing of millions of data rows. Because the Rails ORM create an object for each data row, we end up using a lot of memory. We had to get a 2GB memory server to hold up the project. Even after we avoided the ORM (which removes the pleasure of coding in Rails), the memory usage was still high.

Sure, we could process the data rows outside of Rails in C but because the processing of data rows is an integral part of the project, that would mean coding 80% in C and 20% in rails. Not exactly an enjoyable experience.

So we rewrote it in PHP and avoid objects and use just functions and hashes/arrays. And it worked very well for us. The site render time drops from 0.8s to 0.03s. Memory usage rarely exceeds 100MB.

4 comments

AR usage is one of my main concerns. I myself am a Python guy with good proficiency and understanding of Rails, but we employ mostly Rails people. Our biggest project right now uses Rails for the API and website and several background daemons (work queues) in Python.

I'm already rewriting the API code in a minimal Merb app, which uses a lot fewer memory and can-haz C-based ORM code with DataMapper. My plan in the future is to try and push possible migration of the Rails-based site code to Merb as well.

Interesting to see yet another company starting out with ruby on rails and then rewriting the whole thing in PHP when it has to scale. There seems to be a pattern to it...
Had a similar situation in a Python project. Got it working by adding a few Python callbacks to the SQL as functions. The code stayed in the same language and memory consumption flatlined. Don't know if that is easy to do from RnR, though.
You do know that you can connect to databases and do stuff in Ruby without AR, right?
Yes. That's what we did. But the memory usage was still higher than the PHP option.