I submitted my request to register the namespace to [EMAIL PROTECTED]
through the pause.perl.org interface. Before I upload the module, I
figured I'd send a email here, to double check my logic.
Basically, here's my "rationale" from the namespace registration
request:
I plan on utilizing information contained in the /proc filesystem
to allow the module to mediate the child processes based on
constraints which may affect over all system performance. The goal
of the module is to have a smart parent process that can stop
forking processes when the machine comes under heavy load, either
from the children, or other external programs. Additionally, it
encapsulates the child program in a sub routine, making code look a
little cleaner, and slightly more maintainable. As of right now, the
code I have can only control the start of processes, eventually, I'd
like to extend the module to be able to control children currently
running, perhaps enabling the parent process to suspend or terminate
children based on the health of the system.
I should be uploading soon. I want to make sure I have adequate tests
and documentation from the first release so I don't get lazy and not put
it in. It's similar to Parallel::ForkManager, but the interface is
completely different. I wanted to abstract out the concept of the
parent/child to make development of perl programs that process a long
list of data slightly easier.
Here's a sample interface:
my $forker = Linux::ForkControl->new(
WatchCount => 1,
MaxKids => 50,
MinKids => 2,
WatchLoad => 1,
MaxLoad => 5.40,
Code => \&process
);
foreach my $host (map { $_='host'.$_.'.domain.com' } (1..400)) {
$forker->run($host);
}
sub process {
my $host = shift;
# do something with this host
return 0;
}
The module handles all of the quirks of forking, and helps prevent
against fork bombing the server. Right now, only "WatchLoad" and
"WatchCount" work, but the idea is to extend the module using the /proc
filesystem (hence the name space) to be able to limit based on
memory/cpu constraints. That way, the programmer has an interface to
make their programs able to respond to a server under heavy load. By
adjusting the load parameter you could limit the number of child
processes your program adds to an already bogged down server. I was
using this module to control backend programs that collected information
about the network. Some of those programs had to run once an hour, and
during the day, I wanted the backend to yield to user generated load on
the machine.
So I guess, two questions:
1) Anyone see this as useful?
2) Is 'Linux::ForkControl' a decent name for this module?
--
Brad Lhotsky <[EMAIL PROTECTED]>