From e4853959500b5004b2476a454983f406ad93b2f2 Mon Sep 17 00:00:00 2001 From: Brice Schaffner Date: Mon, 12 Jun 2023 16:21:23 +0200 Subject: [PATCH] BGDIINF_SB-2951: Added gunicorn worker tmp dir config This is needed in order to improve performance on container deployment. --- README.md | 1 + app/settings.py | 1 + wsgi.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/README.md b/README.md index c86610cb..9e56951a 100644 --- a/README.md +++ b/README.md @@ -118,3 +118,4 @@ The service is configured by Environment Variable: | PRELOAD_RASTER_FILES | `False` | Preload raster files at startup. If not set they will be loaded during first request | | ALTI_WORKERS | `0` | Number of workers. `0` or negative value means that the number of worker are computed from the number of cpu | | DFT_CACHE_HEADER | `public, max-age=86400` | Default cache settings for successful GET, HEAD and OPTIONS requests | +| GUNICORN_WORKER_TMP_DIR | `None` | This should be set to an tmpfs file system for better performance. See https://docs.gunicorn.org/en/stable/settings.html#worker-tmp-dir. | diff --git a/app/settings.py b/app/settings.py index e318beba..a25e67f5 100644 --- a/app/settings.py +++ b/app/settings.py @@ -17,3 +17,4 @@ TRAP_HTTP_EXCEPTIONS = True VALID_SRID = [21781, 2056] +GUNICORN_WORKER_TMP_DIR = os.getenv("GUNICORN_WORKER_TMP_DIR", None) diff --git a/wsgi.py b/wsgi.py index 77dfdb4c..c74233bb 100644 --- a/wsgi.py +++ b/wsgi.py @@ -5,6 +5,7 @@ from app import app as application from app.helpers import get_logging_cfg from app.settings import ALTI_WORKERS +from app.settings import GUNICORN_WORKER_TMP_DIR from app.settings import HTTP_PORT @@ -38,6 +39,7 @@ def load(self): 'workers': ALTI_WORKERS, 'access_log_format': '%(h)s %(l)s %(u)s "%(r)s" %(s)s %(B)s Bytes ' '"%(f)s" "%(a)s" %(L)ss', + 'worker_tmp_dir': GUNICORN_WORKER_TMP_DIR, 'timeout': 60, 'logconfig_dict': get_logging_cfg() }