Create os_workers fact

This change adds a new fact that can be used as the default values for
any worker configuration. When used this fact will reduce the number of
default workers configured for services. Previously we were using
$::processorcount which could lead to excessive memory consumption or
connection limits being execeeded when services were deployed on
baremetal with large number of processors. The os_workers fact uses the
larger of two following values, '2' or '# processors / 4' but will not
exceed '8'.

Change-Id: Ia588817fde9203a134bc9eaad9a5bd5453d7639a
This commit is contained in:
Alex Schultz 2016-09-22 16:32:14 -06:00
parent e6e3ee03d0
commit 1b6c0a7272
2 changed files with 26 additions and 0 deletions

20
lib/facter/os_workers.rb Normal file
View File

@ -0,0 +1,20 @@
#
# We've found that using $::processorcount for workers/threads can lead to
# unexpected memory or process counts for people deploying on baremetal or
# if they have large number of cpus. This fact allows us to tweak the formula
# used to determine number of workers in a single place but use it across all
# modules.
#
# The value for os_workers is max between '(<# processors> / 4)' and '2' with
# a cap of 8.
#
# This fact can be overloaded by an external fact from /etc/factor/facts.d if
# a user would like to provide their own default value.
#
Facter.add(:os_workers) do
has_weight 100
setcode do
processors = Factor.value('processorcount')
[ [ (processors.to_i / 4), 2 ].max, 8 ].min
end
end

View File

@ -0,0 +1,6 @@
---
features:
- Created a new fact called $::os_workers to be used as the defaults for any
of the openstack service worker configurations. This fact will have a value
between '2' and '8'. The value of this fact is the larger value between '2'
and the number of processors divided by '4' but will not exceed '8'.