Skip to content

[ERP-4395] Use same uwsgi config as base trrf#116

Open
ScriptSmith wants to merge 3 commits intonext_releasefrom
ERP-4395-uwsgi-fix
Open

[ERP-4395] Use same uwsgi config as base trrf#116
ScriptSmith wants to merge 3 commits intonext_releasefrom
ERP-4395-uwsgi-fix

Conversation

@ScriptSmith
Copy link
Member

Creating the get_wsgi_application on each request was causing a large memory drain in the new architecture, possibly due to different .so loading strategies used in the new uv style 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 unused socket-9100 vassal + 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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

ScriptSmith and others added 2 commits February 17, 2026 14:49
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@ppettitau ppettitau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great find! Interested to see how benchmarking goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments