Colin Watson has proposed merging ~cjwatson/launchpad:loggerhead-max-requests 
into launchpad:master.

Commit message:
loggerhead: Set Gunicorn max_requests to 2000

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/454760

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.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of 
~cjwatson/launchpad:loggerhead-max-requests into launchpad:master.
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):
     )
 
 
+# XXX cjwatson 2023-10-29: Refactor this so that the charm can supply the
+# gunicorn configuration.
 class LoggerheadApplication(Application):
     def __init__(self, **kwargs):
         self.options = kwargs
@@ -140,6 +142,9 @@ class LoggerheadApplication(Application):
             "forwarded_allow_ips": "*",
             "logger_class": "launchpad_loggerhead.wsgi.LoggerheadLogger",
             "loglevel": "debug",
+            # This is set relatively low to work around memory leaks on
+            # Python 3.
+            "max_requests": 2000,
             "on_starting": _on_starting_hook,
             "pidfile": pidfile_path("codebrowse"),
             "preload_app": True,
_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to