Reputation: 695
As far as I know, when we run Ruby applications on 64-bit Ruby, it consumes more memory than 32-bit Ruby, this is due to pointer address-space.
My machine has 64GB RAM, so in order to access the full 64GB of memory, I installed a 64-bit OS.
I had noticed that running my Ruby on Rails application on 64-bit Ruby consumes more RAM than 32-bit Ruby. I am using Phusion Passenger so it forks or creates new Ruby processes for each request, so each individual Ruby process (user request) is limited to 2 GB in 32-bit Ruby or the overall Ruby process is limited to access only 2GB in 32-bit Ruby.
My Rails application codebase is large and I plan to replicate the same code as multiple Rails applications for multiple clients in a single server so every MB of RAM is important for me, so if more RAM is free I can run additional applications for additional clients.
For more information about the application architecture see "(Using phusion passenger + Nginx) running same rails app with multiple instance names with same port (80)".
Upvotes: 2
Views: 4026
Reputation: 125708
Is it possible to install a 32-bit Ruby on 64-bit OS?
By installing a 32-bit Ruby on 64-bit OS, will my 32-bit Ruby be able to use 64 GB RAM?
What are the pros and cons of running 32-bit Ruby on a 64-bit OS?
You're worrying about nothing, though. The pointer sizes going from 32-bit (4 bytes) to 64-bits (8 bytes) only affects the pointers. If you have 64 GB of RAM and a 64-bit processor that can use them, use the 64-bit version.
Upvotes: 4
Reputation: 160551
...I plan to replicate the same code as multiple Rails applications for multiple clients in a single server so every MB of RAM is important for me...
Don't write monolithic applications, write smaller Rails apps that call central code that handles as much processing as possible for all apps calling it. It'd be a tiny bit slower, but much more efficient memory-wise.
Look into something like RabbitMQ as the backend. It's amazingly efficient and great for this sort of task. The AMQP gem is your friend.
Throw your data around the queues using JSON. It makes it easy to debug.
Upvotes: 2