Hi all,
I spent some time working on the missing apache_like feature in FPM.
The attached patch is the first version and is for testing.
Changes:
1- rename apache_like to dynamic (in conf file and in source file)
2- add the dynamic spawning algorithm
The algorithm is based on the mod_worker from apache httpd
Algorihtm:
check start_servers, min_spare_servers, max_spare_servers
if start_server is not set, set it to (min_spare + (max_spare - min_spare) / 2)
for each pool, set a variable spawn_rate to 1
set a 1s timer event to perform idle server maintenance
each second
for each pool {
calculate nb_idle, number of idle process (based on
child->time_accepted which is set when a child accept() call returns
and reset when it call accept())
if idle > max_spare {
kill the oldest idle child
set spawn_rate to 1
continue to next pool
}
if idle < min_spare {
set nb_children to MIN(spawn_rate, (min_spare - nb_idle))
create nb_children
if (spawn_rate < 32) {
spawn_rate * 2
}
continue to next next pool
}
// nothing has been done (no fork and no kill)
reset spawn_rate to 1
continue to next pool
}
spawn_rate is used to increase the number of child to create when
there is a lot of children to create at once. The first iteration it
will create 1, then 2, then 4, then 8, then 16.
I didn't do anything about handling the gracefull restart. I'll check
that later.
You can test it and make me returns.
Hope it helps
++ Jerome