Cap the number of worker threads

Users can configure the number of worker threads however when it's
not specified the calculated number of workers can get too large on
hosts with a large number of CPUs.

Change-Id: Idda6e476e9e9b5842c4cc03e9853ec31d123abc5
This commit is contained in:
Ravi Gummadi 2017-02-23 05:34:06 -05:00
parent 0f87667b89
commit 33e7ad0400
3 changed files with 9 additions and 7 deletions

View File

@ -13,9 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# If ``repo_nginx_threads`` is unset the system will use half the number of available VCPUS to
# compute the number of api workers to use.
# repo_nginx_threads: 16
## Cap the maximum number of threads / workers when a user value is unspecified.
repo_nginx_threads_max: 16
repo_nginx_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, repo_nginx_threads_max] | min }}"
## APT Cache Options
cache_timeout: 600

View File

@ -0,0 +1,5 @@
---
features:
- Capping the default value for the variable ``repo_nginx_workers`` to
16 when the user doesn't configure this variable. Default value is half
the number of vCPUs available on the machine with a capping value of 16.

View File

@ -1,10 +1,7 @@
user {{ repo_service_user_name }} {{ repo_service_group_name }};
pid {{ repo_nginx_pid }};
{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %}
{% set api_threads = _api_threads if _api_threads > 0 else 1 %}
worker_processes {{ repo_nginx_threads | default(api_threads) }};
worker_processes {{ repo_nginx_threads }};
events {
worker_connections {{ repo_worker_connections }};