简体   繁体   中英

Serving multiple Rails applications through one ruby interpreter instance

Given that each Ruby-On-Rails application needs at least about 40MBs of memory, I was wondering if there is a way of running multiple rails-application instances (different ones) over one interpreter of Ruby so that all shared libraries (rmagick etc) are shared between different application instances, saving space.

If that would be possible, then, I could be running 5-6 rails applications in a single 256RAM virtual server.

Is that possible?

I don't think this is possible without substantially changing the current code base.

But all is not lost.

If these websites are fairly low traffic and you have a fast vps you should take in mind that mod passenger drops the instances from memory if they're inactive for a while. So in theory you could run an unlimited amount of applications as long as you only have a few active at the same time. The price is a slower response on the first request that loads the instance.

Another option would be to load all the shared libraries, then fork off as many child processes as you have apps (use Process.fork ) and run a different app in each child.

Pages of memory which are only read and not written will be shared between the parent and child processes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM