in reply to Have children maintain themselves or main script maintain children.

My question is which way is more resourceful? Is it good for the children to die and re-spawn like that or would it be better to have them stay alive forever until forced to die and maintain their own set of code?

This depends on what your children are doing, and what their memory usage patterns are. Perl does garbage collect, but it does so within a memory arena that grows but never shrinks. You might find that you need to kill and re-spawn your child processes just to be resource friendly.

This problem appears in a number of different forms, and many words have been written on how to write servers that pre-spawn (and recycle) their children. The Perl Cookbook devotes part of a chapter to it, and merlyn has written several Web Techniques articles that cover that ground.

  • Comment on Re: Have children maintain themselves or main script maintain children.

Replies are listed 'Best First'.
Re: Re: Have children maintain themselves or main script maintain children.
by the_0ne (Pilgrim) on May 11, 2001 at 18:39 UTC
    Actually a lot of the code came straight from The Perl Cookbook and then we modified it greatly because it wasn't doing what we wanted to the extent we wanted. I haven't checked out many of merlyn's articles on forking though. I'll have to do that.