20474: Changes RailsAPI queue size to be 10% more than controller's.
[arvados.git] / tools / salt-install / config_examples / multi_host / aws / pillars / nginx_passenger.sls
index 28cc748dacee19185a1a7cf37f7027cbaaa0d755..7bbf9ae618a3c065e78af5ecfaad8d126c98eb62 100644 (file)
@@ -9,28 +9,44 @@
 {%- set passenger_mod = '/usr/lib64/nginx/modules/ngx_http_passenger_module.so'
                           if grains.osfinger in ('CentOS Linux-7',) else
                         '/usr/lib/nginx/modules/ngx_http_passenger_module.so' %}
-{%- set passenger_ruby = '/usr/local/rvm/rubies/ruby-2.7.2/bin/ruby'
-                           if grains.osfinger in ('CentOS Linux-7', 'Ubuntu-18.04',) else
+{%- 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' %}
 
 ### NGINX
 nginx:
-  install_from_phusionpassenger: true
+  __NGINX_INSTALL_SOURCE__: true
   lookup:
     passenger_package: {{ passenger_pkg }}
   ### PASSENGER
   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 %}
+    # 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 }}
+    {%- endif %}
 
   ### SERVER
   server:
     config:
+      # Needed for RVM, harmless otherwise. Cf. https://dev.arvados.org/issues/19015
+      env: GEM_HOME
+      # As we now differentiate where passenger is required or not, we need to
+      # load this module conditionally, so we add this conditional just to use
+      # the same pillar file
+      {% if "install_from_phusionpassenger" == "__NGINX_INSTALL_SOURCE__" %}
       # This is required to get the passenger module loaded
       # In Debian it can be done with this
       # include: 'modules-enabled/*.conf'
       load_module: {{ passenger_mod }}
-
-      worker_processes: 4
+      {% endif %}
+      worker_processes: {{ "__CONTROLLER_NGINX_WORKERS__" or grains['num_cpus'] }}
+      worker_rlimit_nofile: 4096
+      events:
+        worker_connections: 1024
 
   ### SNIPPETS
   snippets: