launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #29920
[Merge] ~cjwatson/launchpad:charm-wsgi-worker-max-requests into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:charm-wsgi-worker-max-requests into launchpad:master.
Commit message:
charm: Reduce max_requests and make it configurable
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/441193
Our Juju-deployed appservers currently have a little less memory than our bare-metal ones, so memory leaks cause a problem slightly earlier. Reduce the Gunicorn `max_requests` setting to cope with this, and make it configurable using `juju config`.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:charm-wsgi-worker-max-requests into launchpad:master.
diff --git a/charm/launchpad-appserver/config.yaml b/charm/launchpad-appserver/config.yaml
index 93586e2..f016031 100644
--- a/charm/launchpad-appserver/config.yaml
+++ b/charm/launchpad-appserver/config.yaml
@@ -47,6 +47,12 @@ options:
type: int
description: Port for the main application server.
default: 8085
+ wsgi_worker_max_requests:
+ type: int
+ description: >
+ Restart WSGI worker processes after handling this many requests. This
+ works around memory leaks.
+ default: 1000
wsgi_workers:
type: int
default: 0
diff --git a/charm/launchpad-appserver/templates/gunicorn.conf.py.j2 b/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
index 09d8866..19a2ad1 100644
--- a/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
+++ b/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
@@ -3,7 +3,7 @@ workers = {{ wsgi_workers }}
# Incompatible with `reload = True`, but that's fine for a Juju deployment.
preload_app = True
# This is set relatively low to work around memory leaks on Python 3.
-max_requests = 2000
+max_requests = {{ wsgi_worker_max_requests }}
log_level = "DEBUG"
# Must be higher than the highest hard_timeout feature rule.
timeout = 65
Follow ups