[ERP-4395] Use same uwsgi config as base trrf#116
Open
ScriptSmith wants to merge 3 commits intonext_releasefrom
Open
[ERP-4395] Use same uwsgi config as base trrf#116ScriptSmith wants to merge 3 commits intonext_releasefrom
ScriptSmith wants to merge 3 commits intonext_releasefrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a memory drain issue by ensuring the Django WSGI application is instantiated once at module load time rather than on every request. It also adds enhanced logging capabilities to track user IDs and request metrics in uwsgi logs. The changes are ported from TRRF PR #673.
Changes:
- Modified wsgi application to instantiate once at module level instead of per-request
- Added enhanced logging with user_id tracking and request metrics via uwsgi log variables
- Extended uwsgi log format to include custom variables (app, current_req, total_req, user_id)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| uwsgi/django.wsgi | Refactored to create wsgi_application once at module level and added logging instrumentation for request tracking |
| uwsgi/docker.ini | Added comprehensive log-format configuration to display enhanced request metrics |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
ppettitau
approved these changes
Feb 17, 2026
Contributor
ppettitau
left a comment
There was a problem hiding this comment.
Great find! Interested to see how benchmarking goes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating the
get_wsgi_applicationon each request was causing a large memory drain in the new architecture, possibly due to different.soloading strategies used in the newuvstyle dockerfiles. But it was probably also causing perf issues before the switch to uv anyway, this just tipped them over the edge.This change brings in the changes that @Lexiel46 added to TRRF a while ago in eresearchqut/trrf#673, that never made it into the registries themselves.
Also note my previous comment in that PR, so there might still be some lingering issue: https://github.com/eresearchqut/trrf/pull/673/changes#r1503456754. I can see that adding that
--ini "${UWSGI_OPTS}"arg appears to spawn an additional uwsgi process, which I think is the unusedsocket-9100vassal + one of the processes becomes an 'emporer', so I will investigate that in a separate PR to TRRF.Once approved, I'll benchmark memory usage again, and then make these same changes in arrk and the cookiecutter project