From 3f3a67356bed42cebccc0139dc6090000dd4e6cf Mon Sep 17 00:00:00 2001 From: razbroc Date: Mon, 27 Jul 2026 16:00:56 +0300 Subject: [PATCH 1/2] perf(uwsgi): set lazy-app = false so the master preforks the app Flip the chart's uwsgi ini to load mapproxy.yaml once in the master and fork workers from it, so the parsed config is shared copy-on-write instead of being parsed once per worker. Safe only on top of the _init_telemetry() dispatch: app.py detects that it was imported in the master and defers provider construction to a postfork hook, so each worker still gets its own export threads and its own gRPC channels. The replaced comment claimed the opposite of the value it annotated ("Fork workers after app load (required for OTel)" on lazy-app = true) and carried a stale todo. Refs: MAPCO-11223, MAPCO-11221 --- helm/config/mapProxyUwsgi.ini | 5 ++++- readme.md | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/helm/config/mapProxyUwsgi.ini b/helm/config/mapProxyUwsgi.ini index 7474272..0f62373 100644 --- a/helm/config/mapProxyUwsgi.ini +++ b/helm/config/mapProxyUwsgi.ini @@ -13,7 +13,10 @@ processes = {{ .Values.mapproxy.uwsgi.processes }} ; Maximum number of workers a threads = {{ .Values.mapproxy.uwsgi.threads }} enable-threads = true master = true -lazy-app = true ; Fork workers after app load (required for OTel) todo check this variable effect +; Load the app once in the master, then fork. Workers share the parsed mapproxy.yaml +; copy-on-write. app.py builds the OTel providers in a postfork hook so their export +; threads and gRPC channels are still created per worker — see src/app.py. +lazy-app = false py-callos-afterfork = true ; allow workers to trap signals ; cheaper = 2 ; Minimum number of workers allowed disable-logging = {{ .Values.mapproxy.uwsgi.disableLogging }} diff --git a/readme.md b/readme.md index 007d965..a231a32 100644 --- a/readme.md +++ b/readme.md @@ -370,7 +370,7 @@ The container starts uWSGI with the following fixed flags (not configurable at r | `--socket 0.0.0.0:3031` | uwsgi binary protocol — use as nginx upstream | | `--http-socket 0.0.0.0:8080` | plain HTTP — use for liveness probes and direct access | | `--master` | master process manages workers | -| `--lazy-app` | workers load `app.py` **after** fork — telemetry initialises per worker via the dispatch in `app.py` | +| `lazy-app = false` | master loads `app.py` once, then forks — workers share the parsed config copy-on-write | | `--harakiri 120` | kill workers that take > 120 s | | `--max-requests 1000` | recycle worker after 1000 requests | | `--reload-on-rss 2048` | recycle worker if RSS exceeds 2 GB | From 5c0dc21d8e54d7c015949c06920a3791234e3a05 Mon Sep 17 00:00:00 2001 From: razbroc <77406876+razbroc@users.noreply.github.com> Date: Sun, 2 Aug 2026 11:28:52 +0300 Subject: [PATCH 2/2] Update helm/config/mapProxyUwsgi.ini Co-authored-by: Shlomi k <65117898+CL-SHLOMIKONCHA@users.noreply.github.com> --- helm/config/mapProxyUwsgi.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/config/mapProxyUwsgi.ini b/helm/config/mapProxyUwsgi.ini index 0f62373..27d4838 100644 --- a/helm/config/mapProxyUwsgi.ini +++ b/helm/config/mapProxyUwsgi.ini @@ -16,7 +16,7 @@ master = true ; Load the app once in the master, then fork. Workers share the parsed mapproxy.yaml ; copy-on-write. app.py builds the OTel providers in a postfork hook so their export ; threads and gRPC channels are still created per worker — see src/app.py. -lazy-app = false +; lazy-app = false py-callos-afterfork = true ; allow workers to trap signals ; cheaper = 2 ; Minimum number of workers allowed disable-logging = {{ .Values.mapproxy.uwsgi.disableLogging }}