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
diff --git a/lib/launchpad_loggerhead/wsgi.py b/lib/launchpad_loggerhead/wsgi.py
index 00defe8..23322d2 100644
--- a/lib/launchpad_loggerhead/wsgi.py
+++ b/lib/launchpad_loggerhead/wsgi.py
@@ -113,6 +113,8 @@ def _on_starting_hook(arbiter):
113 )113 )
114114
115115
116# XXX cjwatson 2023-10-29: Refactor this so that the charm can supply the
117# gunicorn configuration.
116class LoggerheadApplication(Application):118class LoggerheadApplication(Application):
117 def __init__(self, **kwargs):119 def __init__(self, **kwargs):
118 self.options = kwargs120 self.options = kwargs
@@ -140,6 +142,9 @@ class LoggerheadApplication(Application):
140 "forwarded_allow_ips": "*",142 "forwarded_allow_ips": "*",
141 "logger_class": "launchpad_loggerhead.wsgi.LoggerheadLogger",143 "logger_class": "launchpad_loggerhead.wsgi.LoggerheadLogger",
142 "loglevel": "debug",144 "loglevel": "debug",
145 # This is set relatively low to work around memory leaks on
146 # Python 3.
147 "max_requests": 2000,
143 "on_starting": _on_starting_hook,148 "on_starting": _on_starting_hook,
144 "pidfile": pidfile_path("codebrowse"),149 "pidfile": pidfile_path("codebrowse"),
145 "preload_app": True,150 "preload_app": True,

Subscribers

People subscribed via source and target branches

to status/vote changes: