Net::Server::PreFork - Net::Server personality |
Net::Server::PreFork - Net::Server personality
use Net::Server::PreFork; @ISA = qw(Net::Server::PreFork);
sub process_request { #...code... }
__PACKAGE__->run();
Please read the pod on Net::Server and Net::Server::PreForkSimple first. This module is a personality, or extension, or sub class, of the Net::Server::PreForkSimple class which is a sub class of Net::Server. See the Net::Server::PreForkSimple manpage.
This personality binds to one or more ports and then forks
min_servers
child process. The server will make sure
that at any given time there are min_spare_servers
available
to receive a client request, up to max_servers
. Each of
these children will process up to max_requests
client
connections. This type is good for a heavily hit site, and
should scale well for most applications. (Multi port accept
is accomplished using flock to serialize the children).
Please see the sample listed in Net::Server.
In addition to the command line arguments of the Net::Server base class and the Net::Server::PreForkSimple parent class, Net::Server::PreFork contains several other configurable parameters. You really should also see the Net::Server::PreForkSimple manpage.
Key Value Default min_servers \d+ 5 min_spare_servers \d+ 2 max_spare_servers \d+ 10 max_servers \d+ 50 max_requests \d+ 1000
serialize (flock|semaphore|pipe) undef # serialize defaults to flock on multi_port or on Solaris lock_file "filename" POSIX::tmpnam
check_for_dead \d+ 30 check_for_waiting \d+ 10
max_dequeue \d+ undef check_for_dequeue \d+ undef
child_communication 1 undef
Net::Server::PreFork
allows for the use of a
configuration file to read in server parameters. The format
of this conf file is simple key value pairs. Comments and
white space are ignored.
#-------------- file test.conf --------------
### server information min_servers 20 max_servers 80 min_spare_servers 10 min_spare_servers 15
max_requests 1000
### user and group to become user somebody group everybody
### logging ? log_file /var/log/server.log log_level 3 pid_file /tmp/server.pid
### access control allow .+\.(net|com) allow domain\.com deny a.+
### background the process? background 1
### ports to bind host 127.0.0.1 port localhost:20204 port 20205
### reverse lookups ? # reverse_lookups on
### enable child communication ? # child_communication
#-------------- file test.conf --------------
Process flow follows Net::Server until the loop phase. At
this point min_servers
are forked and wait for
connections. When a child accepts a connection, finishs
processing a client, or exits, it relays that information to
the parent, which keeps track and makes sure there are
enough children to fulfill min_servers
, min_spare_servers
,
max_spare_servers
, and max_servers
.
The PreFork server has the following hooks in addition to the hooks provided by PreForkSimple. See the Net::Server::PreForkSimple manpage.
$self->parent_read_hook()
$self->child_is_talking_hook()
Paul T. Seamons paul@seamons.com
Please see also the Net::Server::Fork manpage, the Net::Server::INET manpage, the Net::Server::PreForkSimple manpage, the Net::Server::MultiType manpage, the Net::Server::Single manpage the Net::Server::SIG manpage the Net::Server::Daemonize manpage the Net::Server::Proto manpage
Net::Server::PreFork - Net::Server personality |