Set default --max-requests for API workers to prevent unbounded RSS growth#7529
Set default --max-requests for API workers to prevent unbounded RSS growth#7529
Conversation
b1b399a to
b545426
Compare
pulpcore/app/entrypoint.py
Outdated
| PulpApiWorker.__module__ + "." + PulpApiWorker.__qualname__, | ||
| enforced=True, | ||
| ) | ||
| if self.cfg.max_requests == 0: |
There was a problem hiding this comment.
The comment describes disabling recycling by setting --max-requests 0, but it would seem like this would explicitly use the defaults in that scenario. Am I missing something?
…rowth API workers currently run with max_requests=0 (unlimited lifetime), which means glibc heap fragmentation accumulates indefinitely and RSS grows without bound (~1 kB/request from normal Django ORM alloc/dealloc churn). Set max_requests=10000 and max_requests_jitter=500 as defaults for PulpApiWorker when gunicorn's effective max_requests is still 0 and the user did not pass --max-requests on the pulpcore-api CLI. An explicit --max-requests 0 disables recycling (gunicorn semantics) and is not overridden. Workers are gracefully recycled after ~10000 requests, resetting fragmented heap memory. Jitter prevents all workers from restarting simultaneously. Documented in docs/admin/learn/architecture.md. closes pulp#7482 Assisted-by: Claude (Anthropic) Made-with: Cursor
d294550 to
b005762
Compare
|
@dralley Good catch - I had that backwards in the first version. Gunicorn already uses I’ve changed it so we only apply the 10000/500 defaults when Latest push is one squashed commit with that fix. |
Summary
max_requests=10000andmax_requests_jitter=500as defaults for API workersmax_requestshas not been explicitly configured (via CLI, config file, orGUNICORN_CMD_ARGS)Context
Follow-up from the discussion in #7481 where @ggainey and @dralley agreed that setting sensible
--max-requestsdefaults is the right approach. See #7482 for the full profiling data showing ~1 kB/request RSS growth from glibc heap fragmentation under normal Django ORM workload.Implementation note
The defaults are set in
PulpcoreApiApplication.load_app_specific_config()rather than as click option defaults to preserve the config precedence chain: if a user has already configuredmax_requestsvia a config file,GUNICORN_CMD_ARGS, or CLI flag, their value is respected and not overridden.Test plan
--max-requests 0on CLI disables recyclingGUNICORN_CMD_ARGS="--max-requests 5000"overrides the default📜 Checklist
See: Pull Request Walkthrough
Made with Cursor