{ "pm.start_servers", &fpm_conf_set_integer, WPO(pm_start_servers) },
{ "pm.min_spare_servers", &fpm_conf_set_integer, WPO(pm_min_spare_servers) },
{ "pm.max_spare_servers", &fpm_conf_set_integer, WPO(pm_max_spare_servers) },
+ { "pm.max_spawn_rate", &fpm_conf_set_integer, WPO(pm_max_spawn_rate) },
{ "pm.process_idle_timeout", &fpm_conf_set_time, WPO(pm_process_idle_timeout) },
{ "pm.max_requests", &fpm_conf_set_integer, WPO(pm_max_requests) },
{ "pm.status_path", &fpm_conf_set_string, WPO(pm_status_path) },
memset(wp->config, 0, sizeof(struct fpm_worker_pool_config_s));
wp->config->listen_backlog = FPM_BACKLOG_DEFAULT;
+ wp->config->pm_max_spawn_rate = 32; /* 32 by default */
wp->config->pm_process_idle_timeout = 10; /* 10s by default */
wp->config->process_priority = 64; /* 64 means unset */
wp->config->process_dumpable = 0;
return -1;
}
- /* pm.start_servers, pm.min_spare_servers, pm.max_spare_servers */
+ /* pm.start_servers, pm.min_spare_servers, pm.max_spare_servers, pm.max_spawn_rate */
if (wp->config->pm == PM_STYLE_DYNAMIC) {
struct fpm_worker_pool_config_s *config = wp->config;
zlog(ZLOG_ALERT, "[pool %s] pm.start_servers(%d) must not be less than pm.min_spare_servers(%d) and not greater than pm.max_spare_servers(%d)", wp->config->name, config->pm_start_servers, config->pm_min_spare_servers, config->pm_max_spare_servers);
return -1;
}
+
+ if (config->pm_max_spawn_rate < 1) {
+ zlog(ZLOG_ALERT, "[pool %s] pm.max_spawn_rate must be a positive value", wp->config->name);
+ return -1;
+ }
} else if (wp->config->pm == PM_STYLE_ONDEMAND) {
struct fpm_worker_pool_config_s *config = wp->config;
zlog(ZLOG_NOTICE, "\tpm.start_servers = %d", wp->config->pm_start_servers);
zlog(ZLOG_NOTICE, "\tpm.min_spare_servers = %d", wp->config->pm_min_spare_servers);
zlog(ZLOG_NOTICE, "\tpm.max_spare_servers = %d", wp->config->pm_max_spare_servers);
+ zlog(ZLOG_NOTICE, "\tpm.max_spawn_rate = %d", wp->config->pm_max_spawn_rate);
zlog(ZLOG_NOTICE, "\tpm.process_idle_timeout = %d", wp->config->pm_process_idle_timeout);
zlog(ZLOG_NOTICE, "\tpm.max_requests = %d", wp->config->pm_max_requests);
zlog(ZLOG_NOTICE, "\tpm.status_path = %s", STR2STR(wp->config->pm_status_path));
return true;
}
+ /**
+ * Expect log config options
+ *
+ * @param array $options
+ * @return bool
+ */
+ public function expectLogConfigOptions(array $options)
+ {
+ $configOptions = $this->getConfigOptions();
+ foreach ($options as $name => $value) {
+ if (!isset($configOptions[$name])) {
+ return $this->error("Expected config option: {$name} = {$value} but {$name} is not set");
+ }
+ if ($configOptions[$name] != $value) {
+ return $this->error(
+ "Expected config option: {$name} = {$value} but got: {$name} = {$configOptions[$name]}"
+ );
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Get set config options
+ *
+ * @return array
+ */
+ private function getConfigOptions()
+ {
+ $options = [];
+
+ foreach ($this->getLogLines(-1) as $line) {
+ preg_match('/.+NOTICE:\s+(.+)\s=\s(.+)/', $line, $matches);
+ if ($matches) {
+ $options[$matches[1]] = $matches[2];
+ }
+ }
+
+ return $options;
+ }
+
/**
* Print content of access log.
*/
; state (waiting to process). If the number
; of 'idle' processes is greater than this
; number then some children will be killed.
+; pm.max_spawn_rate - the maximum number of rate to spawn child
+; processes at once.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 3
+; The number of rate to spawn child processes at once.
+; Note: Used only when pm is set to 'dynamic'
+; Note: Mandatory when pm is set to 'dynamic'
+; Default Value: 32
+;pm.max_spawn_rate = 32
+
; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s