20595: Scales nginx settings depending on max concurrent requests config. 20594-scaling-nginx-settings
authorLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 26 May 2023 18:45:31 +0000 (15:45 -0300)
committerLucas Di Pentima <lucas.dipentima@curii.com>
Fri, 26 May 2023 19:17:32 +0000 (16:17 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas.dipentima@curii.com>

tools/salt-install/config_examples/multi_host/aws/pillars/nginx_passenger.sls

index 7bbf9ae618a3c065e78af5ecfaad8d126c98eb62..b003172330e465173e1f1f200449d5f1bb6a171a 100644 (file)
@@ -12,6 +12,7 @@
 {%- set passenger_ruby = '/usr/local/rvm/wrappers/default/ruby'
                            if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04', 'Debian-10') else
                          '/usr/bin/ruby' %}
+{%- set max_reqs = "__CONTROLLER_MAX_CONCURRENT_REQUESTS__" %}
 
 ### NGINX
 nginx:
@@ -22,11 +23,10 @@ nginx:
   passenger:
     passenger_ruby: {{ passenger_ruby }}
     passenger_max_pool_size: {{ "__CONTROLLER_NGINX_WORKERS__" or grains['num_cpus'] }}
-    {%- set max_reqs = "__CONTROLLER_MAX_CONCURRENT_REQUESTS__" %}
-    {%- if max_reqs != "" and max_reqs is number %}
+    {%- if max_reqs != "" %}
     # Default is 100 -- Configuring this a bit higher than API.MaxConcurrentRequests
     # to be able to handle /metrics requests even on heavy load situations.
-    passenger_max_request_queue_size: {{ (max_reqs * 1.1)|round|int }}
+    passenger_max_request_queue_size: {{ (max_reqs|int * 1.1)|round|int }}
     {%- endif %}
 
   ### SERVER
@@ -44,9 +44,15 @@ nginx:
       load_module: {{ passenger_mod }}
       {% endif %}
       worker_processes: {{ "__CONTROLLER_NGINX_WORKERS__" or grains['num_cpus'] }}
+      {%- if max_reqs != "" %}
+      worker_rlimit_nofile: {{ (max_reqs|int * 3)|round|int }}
+      events:
+        worker_connections: {{ (max_reqs|int * 3)|round|int }}
+      {%- else %}
       worker_rlimit_nofile: 4096
       events:
         worker_connections: 1024
+      {%- endif %}
 
   ### SNIPPETS
   snippets: