Merge ~cjwatson/launchpad:loggerhead-max-requests into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: c7c20d930faad7f3930b3582c9b3aef286f86333
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:loggerhead-max-requests
Merge into: launchpad:master
Diff against target: 23 lines (+5/-0)
1 file modified
lib/launchpad_loggerhead/wsgi.py (+5/-0)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+454760@code.launchpad.net

Commit message

loggerhead: Set Gunicorn max_requests to 2000

Description of the change

We've found with Launchpad itself that the application server leaks memory over time. This is surely a bug somewhere, but it's proven extremely difficult to track down, and a cheap and very effective workaround has been to set `max_requests` in Gunicorn. (See the "Memory leaks" section of https://www.chiark.greenend.org.uk/~cjwatson/blog/lp-python3.html for some background.)

Judging by memory graphs, Loggerhead is behaving in very much the same way, so install the same workaround there.

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/launchpad_loggerhead/wsgi.py b/lib/launchpad_loggerhead/wsgi.py
2index 00defe8..23322d2 100644
3--- a/lib/launchpad_loggerhead/wsgi.py
4+++ b/lib/launchpad_loggerhead/wsgi.py
5@@ -113,6 +113,8 @@ def _on_starting_hook(arbiter):
6 )
7
8
9+# XXX cjwatson 2023-10-29: Refactor this so that the charm can supply the
10+# gunicorn configuration.
11 class LoggerheadApplication(Application):
12 def __init__(self, **kwargs):
13 self.options = kwargs
14@@ -140,6 +142,9 @@ class LoggerheadApplication(Application):
15 "forwarded_allow_ips": "*",
16 "logger_class": "launchpad_loggerhead.wsgi.LoggerheadLogger",
17 "loglevel": "debug",
18+ # This is set relatively low to work around memory leaks on
19+ # Python 3.
20+ "max_requests": 2000,
21 "on_starting": _on_starting_hook,
22 "pidfile": pidfile_path("codebrowse"),
23 "preload_app": True,

Subscribers

People subscribed via source and target branches

to status/vote changes: