diff --git a/defaults/main.yml b/defaults/main.yml index 7b5bd17..44febeb 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml b/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml new file mode 100644 index 0000000..7a94146 --- /dev/null +++ b/releasenotes/notes/capping_repo_nginx_workers-ddbc355855f8fe43.yaml @@ -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. diff --git a/templates/nginx.conf.j2 b/templates/nginx.conf.j2 index 7305277..91092e1 100644 --- a/templates/nginx.conf.j2 +++ b/templates/nginx.conf.j2 @@ -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 }};