[cgiapp] Tasks after fork()'ing a CGI::Application

Daniel Sterling dan at lost-habit.com
Mon Aug 10 11:57:54 EDT 2009


On Mon, Aug 10, 2009 at 11:18 AM, Michael Peters<mpeters at plusthree.com> wrote:
> I would actually suggest that you don't fork your web process to do
> background tasks. The problem is that your web processes are generally much
> heavier than you need which means wasted resources.

I would definitely second this.

Michael suggests using a separate daemon/queue -- that's definitely a
good option, but another possibility would be to do a fork+exec in
your code. With the exec, the existing process state is replaced with
a new process. I've actually done something like this recently, so
feel free to ask if you run into issues. The hard part is getting all
the state you need into the new process; IPC::Open3 can work for this.

-- Dan


More information about the cgiapp mailing list