Change worker defaults to ::os_workers

This patch changes the default worker count from ::processorcount to the
new ::os_workers fact. ::os_workers is based on the number of processors
(currently cpu/4) but is capped at a maximum of 8 worker processors.
This is a much more reasonable default in general and prevents excessive
resource consumption on systems with a large number of CPUs.

Change-Id: Ia95c6b93fa7d2d53eb6fd1dfc6a3106e38d4ce63
This commit is contained in:
Maksym Yatsenko 2016-10-08 01:22:21 +03:00
parent 967ef34c82
commit 03f82512a5
5 changed files with 11 additions and 7 deletions

View File

@ -20,7 +20,7 @@
# #
# [*workers*] # [*workers*]
# (optional) Number of workers for Panko API server. # (optional) Number of workers for Panko API server.
# Defaults to $::processorcount # Defaults to $::os_workers
# #
# [*max_limit*] # [*max_limit*]
# (optional) The maximum number of items returned in a # (optional) The maximum number of items returned in a
@ -55,7 +55,7 @@ class panko::api (
$package_ensure = 'present', $package_ensure = 'present',
$host = '0.0.0.0', $host = '0.0.0.0',
$port = '8779', $port = '8779',
$workers = $::processorcount, $workers = $::os_workers,
$max_limit = 1000, $max_limit = 1000,
$service_name = $::panko::params::api_service_name, $service_name = $::panko::params::api_service_name,
$sync_db = false, $sync_db = false,

View File

@ -51,7 +51,7 @@
# #
# [*threads*] # [*threads*]
# (optional) The number of threads for the vhost. # (optional) The number of threads for the vhost.
# Defaults to $::processorcount # Defaults to $::os_workers
# #
# [*ssl_cert*] # [*ssl_cert*]
# [*ssl_key*] # [*ssl_key*]
@ -87,7 +87,7 @@ class panko::wsgi::apache (
$ssl_crl_path = undef, $ssl_crl_path = undef,
$ssl_crl = undef, $ssl_crl = undef,
$ssl_certs_dir = undef, $ssl_certs_dir = undef,
$threads = $::processorcount, $threads = $::os_workers,
$priority = '10', $priority = '10',
) { ) {

View File

@ -0,0 +1,5 @@
---
other:
- Parameters that control the number of spawned child processes for
distributing processing have had their default value changed from
::processorcount to ::os_workers.

View File

@ -155,7 +155,6 @@ describe 'panko::api' do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts({ facts.merge!(OSDefaults.get_facts({
:concat_basedir => '/var/lib/puppet/concat', :concat_basedir => '/var/lib/puppet/concat',
:processorcount => 2
})) }))
end end

View File

@ -51,7 +51,7 @@ describe 'panko::wsgi::apache' do
:bind_host => '10.42.51.1', :bind_host => '10.42.51.1',
:port => 12345, :port => 12345,
:ssl => false, :ssl => false,
:workers => 37, :workers => 8,
} }
end end
@ -79,7 +79,7 @@ describe 'panko::wsgi::apache' do
context "on #{os}" do context "on #{os}" do
let (:facts) do let (:facts) do
facts.merge!(OSDefaults.get_facts({ facts.merge!(OSDefaults.get_facts({
:processorcount => 42, :os_workers => 4,
:concat_basedir => '/var/lib/puppet/concat', :concat_basedir => '/var/lib/puppet/concat',
:fqdn => 'some.host.tld', :fqdn => 'some.host.tld',
})) }))