Skip to content

Set default --max-requests for API workers to prevent unbounded RSS growth#7529

Open
amasolov wants to merge 1 commit intopulp:mainfrom
amasolov:fix/default-max-requests
Open

Set default --max-requests for API workers to prevent unbounded RSS growth#7529
amasolov wants to merge 1 commit intopulp:mainfrom
amasolov:fix/default-max-requests

Conversation

@amasolov
Copy link

Summary

  • Set max_requests=10000 and max_requests_jitter=500 as defaults for API workers
  • Workers are gracefully recycled after ~10,000 requests, resetting accumulated glibc heap fragmentation
  • Defaults only apply when max_requests has not been explicitly configured (via CLI, config file, or GUNICORN_CMD_ARGS)

Context

Follow-up from the discussion in #7481 where @ggainey and @dralley agreed that setting sensible --max-requests defaults 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 configured max_requests via a config file, GUNICORN_CMD_ARGS, or CLI flag, their value is respected and not overridden.

Test plan

  • Verify workers restart after ~10,000 requests (check gunicorn logs for worker boot messages)
  • Verify --max-requests 0 on CLI disables recycling
  • Verify GUNICORN_CMD_ARGS="--max-requests 5000" overrides the default
  • Verify existing test suite passes

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

See: Pull Request Walkthrough

Made with Cursor

…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. Workers are gracefully recycled after ~10000 requests,
resetting fragmented heap memory. The jitter prevents all workers from
restarting simultaneously.

The defaults only apply when max_requests has not been explicitly
configured (via CLI, config file, or GUNICORN_CMD_ARGS), so existing
deployments that set their own values are unaffected.

closes pulp#7482

Assisted-by: Claude (Anthropic)
Made-with: Cursor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant