Merge ~cjwatson/launchpad:charm-wsgi-worker-max-requests into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 9f1561a1e90f79be61335d2bc07443ead56206f3
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:charm-wsgi-worker-max-requests
Merge into: launchpad:master
Diff against target: 30 lines (+7/-1)
2 files modified
charm/launchpad-appserver/config.yaml (+6/-0)
charm/launchpad-appserver/templates/gunicorn.conf.py.j2 (+1/-1)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Nick Moffitt (community) Approve
Review via email: mp+441193@code.launchpad.net

Commit message

charm: Reduce max_requests and make it configurable

Description of the change

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`.

To post a comment you must log in.
Revision history for this message
Nick Moffitt (nick-moffitt) wrote :

I applied this temporarily to one appserver unit, and can confirm its effectiveness.

review: Approve
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM ๐Ÿ‘๐Ÿผ

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charm/launchpad-appserver/config.yaml b/charm/launchpad-appserver/config.yaml
2index 93586e2..f016031 100644
3--- a/charm/launchpad-appserver/config.yaml
4+++ b/charm/launchpad-appserver/config.yaml
5@@ -47,6 +47,12 @@ options:
6 type: int
7 description: Port for the main application server.
8 default: 8085
9+ wsgi_worker_max_requests:
10+ type: int
11+ description: >
12+ Restart WSGI worker processes after handling this many requests. This
13+ works around memory leaks.
14+ default: 1000
15 wsgi_workers:
16 type: int
17 default: 0
18diff --git a/charm/launchpad-appserver/templates/gunicorn.conf.py.j2 b/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
19index 09d8866..19a2ad1 100644
20--- a/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
21+++ b/charm/launchpad-appserver/templates/gunicorn.conf.py.j2
22@@ -3,7 +3,7 @@ workers = {{ wsgi_workers }}
23 # Incompatible with `reload = True`, but that's fine for a Juju deployment.
24 preload_app = True
25 # This is set relatively low to work around memory leaks on Python 3.
26-max_requests = 2000
27+max_requests = {{ wsgi_worker_max_requests }}
28 log_level = "DEBUG"
29 # Must be higher than the highest hard_timeout feature rule.
30 timeout = 65

Subscribers

People subscribed via source and target branches

to status/vote changes: