ara_api role: Default gunicorn worker count based on CPU cores

The recommended default formula as per gunicorn docs is:

  (2 x $num_cores) + 1

Change-Id: I37ac2051f5b17fdce283e486dfcd5c68d9eacfd0
This commit is contained in:
David Moreau Simard 2020-01-30 11:39:22 -05:00
parent 4d800d1b35
commit e739164b55
No known key found for this signature in database
GPG Key ID: 938880DAFC753E80
2 changed files with 6 additions and 2 deletions

View File

@ -83,6 +83,10 @@ ara_api_wsgi_server: null
# "ara_api_cors_origin_whitelist".
ara_api_wsgi_bind: "127.0.0.1:8000"
# Amount of worker processes for the wsgi server
# Recommended default formula by gunicorn: https://docs.gunicorn.org/en/stable/design.html#how-many-workers
ara_api_wsgi_workers: "{{ ansible_processor_count * ansible_processor_cores * ansible_processor_threads_per_core * 2 + 1 }}"
# When using a frontend server, the domain or address it will be listening on
ara_api_fqdn: "{{ ansible_default_ipv4['address'] | default(ansible_default_ipv6['address']) }}"

View File

@ -8,9 +8,9 @@ RuntimeDirectory=ara-api
WorkingDirectory={{ ara_api_root_dir }}
Environment=ARA_SETTINGS={{ ara_api_settings }}
{% if ara_api_venv %}
ExecStart={{ ara_api_venv_path }}/bin/gunicorn --workers=4 --bind {{ ara_api_wsgi_bind }} {{ _ara_api_wsgi_application | default('ara.server.wsgi') }}
ExecStart={{ ara_api_venv_path }}/bin/gunicorn --workers={{ ara_api_wsgi_workers }} --bind {{ ara_api_wsgi_bind }} {{ _ara_api_wsgi_application | default('ara.server.wsgi') }}
{% else %}
ExecStart=gunicorn --workers=4 --bind {{ ara_api_wsgi_bind }} {{ _ara_api_wsgi_application | default('ara.server.wsgi') }}
ExecStart=gunicorn --workers={{ ara_api_wsgi_workers }} --bind {{ ara_api_wsgi_bind }} {{ _ara_api_wsgi_application | default('ara.server.wsgi') }}
{% endif %}
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID