Skip to content

Conversation

@mlabeeb03
Copy link
Contributor

@mlabeeb03 mlabeeb03 commented Dec 31, 2025

PLEASE REACH OUT TO @ahmed-arb FOR UPDATES ON THIS PR.

closes #937

This PR replaces uwsgi with granian.

All uwsgi related docs have been updated.
All uwsgi related patches and configs values have been renamed.
All uwsgi related files have been deleted and replaced with granian equivalents.

Here are the uwsgi configs/features we are currently using and their granian equivalents.

  • static-map = /static=/openedx/staticfiles/

  • static-map = /media=/openedx/media/
    Even though --static-path-route & --static-path-mount are available, they can only server from one path, in order to server both of them we must use caddy.

  • http = 0.0.0.0:8000
    --host & --port

  • buffer-size = 8192
    --http1-buffer-size 8192

  • wsgi-file = $(SERVICE_VARIANT)/wsgi.py
    Use this parameter $SERVICE_VARIANT.wsgi:application

  • processes = $(UWSGI_WORKERS)
    --workers

  • ⚠️ thunder-lock = true
    Apparently granian does not have thundering herd problem, see Related Granian discussion

  • single-interpreter = true

  • enable-threads = true
    Threads are enabled by default. You can explicitly set them with --runtime-mode. Set the number of threads with --runtime-threads.

  • http-keepalive = 1
    --http1-keep-alive enabled by default

  • ❌ add-header = Connection: Keep-Alive
    Can not add arbitrary headers with granian, does this affect us if we have --http1-keep-alive?

  • die-on-term = true
    Granian handles SIGTERM as a shutdown signal by default

  • lazy-apps = false

  • need-app = true

  • no-defer-accept = true

  • master = true

  • py-call-osafterfork = true

  • vacuum = true

  • Reload
    We can define a file in the --reload-paths and changing that file will restart the server. We also need to install the reload dependency and also unable the --reload config.

@mlabeeb03 mlabeeb03 marked this pull request as draft December 31, 2025 14:35
@mlabeeb03 mlabeeb03 force-pushed the labeeb/replace-uwsgi-with-granian branch from 481f368 to e527b3e Compare December 31, 2025 14:38
@ormsbee
Copy link
Contributor

ormsbee commented Jan 5, 2026

Just a warning that I have a suspicion that MIT's switch to granian may have been responsible for exposing a multi-threading related bug in grading. This wouldn't be any fault of granian's, but more a case where granian's deployment strategy exposes already-existing problems. This is highly speculative on my part, and the investigation is ongoing. I just wanted to bring this to your attention early. The bug needs to be fixed regardless, so I don't expect it to block granian in the long term, even if this hypothesis turns out to be true.

@mlabeeb03 mlabeeb03 force-pushed the labeeb/replace-uwsgi-with-granian branch from e527b3e to 7becdfe Compare January 7, 2026 10:22
@mlabeeb03 mlabeeb03 force-pushed the labeeb/replace-uwsgi-with-granian branch from 7becdfe to c5d2e23 Compare January 7, 2026 11:50
Comment on lines +7 to +8
--reload
--reload-paths /openedx/granian-reload-path
Copy link
Contributor

Choose a reason for hiding this comment

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

This is for watching a directory and reloading if there are file changes detected, right? Just out of curiosity, why enable this in a prod environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had a reload-uwsgi command as well. Here is the rational behind doing it. This is just a replacement for that. Now the reload-granian command puts current timestamp in the file mentioned in --reload-paths to trigger a reload.

@ormsbee
Copy link
Contributor

ormsbee commented Jan 9, 2026

Quick update: We believe the multi-threading issue has been fixed, though we're still waiting for MIT to deploy it on their instance next week to verify that it resolves the issues they've been seeing there.

@ahmed-arb ahmed-arb moved this from Pending Triage to In Progress in Tutor project management Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

We must replace uwsgi by something else

2 participants