Apache的进程/线程模型 之 prefork
Prefork
set count_child 0
set count_spare 0
httpd master -startup {
while {$count_child < $StartServers} {
httpd spawn-child
incr count_child
incr count_spare
}
}
httpd child -accept {
incr count_accept +1
incr count_spare -1
httpd master -regulate
}
httpd child -release {
if { $MaxConnectionsPerChild > 0
&& $count_accept >= $MaxConnectionsPerChild
} {
incr count_child -1
} else {
incr count_spare +1
}
httpd -master regulate
}
httpd child -recycle {
incr count_child -1
httpd master -regulate
}
httpd master -regulate {
while {$count_spare > $MaxSpareServers} {
httpd kill-spare
}
while {$count_spare < $MinSpareServers} {
if {$count_child < $MaxRequestWorkers} {
httpd spawn-child
}
}
}