From: Thomas Hurst Date: 2007-02-05T00:58:32+09:00 Subject: Re: Using fork to conserve memory * Daniel DeLorme (dan-ml@dan42.com) wrote: > No, fastcgi creates a bunch of worker processes and loads the full rails > environment in EACH of them. That means a lot of memory (30+ MB for each > process) and a long initialization time (2+ seconds for each process). > > What I'm talking about is loading the large environment once and THEN > forking off worker processes that don't need to go through the expensive > initialization sequence. I've been running simple Ruby FastCGI's using multiple forked processes and external servers using something along the lines of: shared_setup # load libs, logs are normally ok here too STDIN.reopen(TCPServer.new(port)) trap("CHLD") { Process.wait(-1, Process::WNOHANG) } process_count.times do fork do unshared_setup # db connection etc FCGI.each_request {|r| process(r) } end end libfcgi has helper functions to do much of this, be nice if they were added to fcgi.so at some point. -- Thomas 'Freaky' Hurst http://hur.st/