Hacker News new | ask | show | jobs
by surfmike 3776 days ago
if you're running multiple rails processes on a server like this, couldn't you somehow do the initialization in one process, then fork off the new processes? wouldn't that prevent the base libraries from being copied in memory?
2 comments

Yes, http://unicorn.bogomips.org/ popularized this for ruby / rack / rails with its forking model and preload_app option. http://puma.io/ does the same thing, but additionally runs multiple threads in each process.

The garbage collector in Ruby 1.8 / 1.9 negated the benefits of copy-on-write forking, but that's fixed since Ruby 2.0

Yes. Many app servers do this. (Not being super familiar with the Ruby ecosystem, I am not sure specifically which ones.)