Skip to content

Reduce Puma and Pulp worker counts for development tuning - #925

Merged
evgeni merged 1 commit into
theforeman:masterfrom
pablomh:reduce-dev-tuning-resources
Oct 8, 2026
Merged

evgeni merged 1 commit into
theforeman:masterfrom
pablomh:reduce-dev-tuning-resources

Conversation

@pablomh

@pablomh pablomh commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why are you introducing these changes?

Development environments can OOM when syncing several repositories concurrently. The root cause is that foreman_puma_workers and the pulp_*_worker_count vars are computed from live host facts (ansible_facts['processor_nproc'], ansible_facts['memtotal_mb']) rather than from the selected tuning profile. That means --tuning development's 4-core/10GB floor doesn't actually cap resource usage: any dev box above that floor (a common case -- e.g. an 8-core/16GB laptop or CI VM) scales these up automatically, same as it would for medium/large.

Computed at each profile's minimum hardware floor, before this change:

development (4 cores / 10 GB) default (4 cores / 20 GB) medium (8 cores / 32 GB)
foreman_puma_workers 6 6 12
pulp_worker_count 4 4 8
pulp_content_service_worker_count 9 9 17
pulp_api_service_worker_count 5 5 5

development and default land on identical numbers (both have 4 cores as their floor; RAM isn't a factor for Pulp, and only mildly caps Puma), and on any dev box with more than the bare minimum, these climb further, same as medium. development tuning doesn't actually imply "scaled down for a small box" -- it only gates the minimum.

This mirrors the same problem 6c7964810a72 ("limited development Candlepin heap") already fixed for Candlepin's JVM heap.

What are the changes?

Pin foreman_puma_workers, pulp_worker_count, pulp_content_service_worker_count, and pulp_api_service_worker_count to 2 across the board in src/vars/tuning/development.yml, overriding the hardware-scaled role defaults -- same mechanism, same file, same precedent as the existing Candlepin heap override.

After this change:

development (fixed) default (unchanged) medium (unchanged)
foreman_puma_workers 2 6 12
pulp_worker_count 2 4 8
pulp_content_service_worker_count 2 9 17
pulp_api_service_worker_count 2 5 5

default, medium, large, extra-large, and extra-extra-large are untouched and keep scaling from live hardware facts as before; only development is pinned.

Also split/reordered the tuning unit tests to mirror the vars file's key order (Puma -> Pulp -> Candlepin) and factored out the repeated YAML-loading boilerplate into a load_tuning_profile(name) helper + fixture, so a future test for another profile doesn't have to repeat it.

Result

Development deployments use fixed, minimal worker counts, regardless of the actual host's CPU/RAM, significantly reducing memory pressure and avoiding OOM when syncing multiple repositories concurrently in dev environments.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: deb2057f-c7c1-40a5-a8ab-d51e66685585
📥 Commits

Reviewing files that changed from the base of the PR and between 639fc03 and 168e81e.

📒 Files selected for processing (2)
  • src/vars/tuning/development.yml
  • tests/unit/tuning_test.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The development tuning profile sets Foreman Puma and three Pulp worker counts to 2. Unit tests load the profile through a shared fixture and check these values. The Candlepin heap test also uses the fixture and retains its existing expectations.

Changes

Development tuning

Layer / File(s) Summary
Development profile and tests
src/vars/tuning/development.yml, tests/unit/tuning_test.py
The development profile sets Foreman Puma workers and Pulp worker, content-service, and API-service workers to 2. Tests load the profile through a shared fixture and check the worker counts. The Candlepin heap test uses the fixture and retains its 512m minimum and 2g maximum expectations.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: jakduch

Merge Risk: ⚪ Minimal · up to 168e8

The development profile consistently applies the lightweight worker counts chosen for this change. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: reducing Puma and Pulp worker counts for development tuning.
Description check ✅ Passed The description explains the development OOM issue, identifies the affected variables, and describes the proposed tuning and test changes. It is related to the changeset.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 1 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

Comment thread src/vars/tuning/development.yml Outdated
Comment on lines +5 to +9
foreman_puma_workers: 3

pulp_worker_count: 2
pulp_content_service_worker_count: 5
pulp_api_service_worker_count: 3

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the numbers feel arbitrary, so why not go even harder and set 2 for everything?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly did "default / 2", but I don't see why we cannot do that :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

pablomh added a commit to pablomh/foremanctl that referenced this pull request Oct 8, 2026
Per review feedback on PR theforeman#925: the previous numbers (3/2/5/3) were
derived from the pulp_worker_count*2+1 / +1 formulas and felt
arbitrary for a profile that just needs to be as light as possible.
Set foreman_puma_workers, pulp_worker_count,
pulp_content_service_worker_count, and pulp_api_service_worker_count
all to 2.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@evgeni

evgeni commented Oct 8, 2026

Copy link
Copy Markdown
Member

Would you mind squashing and rebasing this? Then the IoP container tests will turn green.

Pulp worker/Puma counts are derived from live ansible_facts
(processor_nproc, memtotal_mb), not from the tuning profile, so any
dev box above the bare 4-core/10GB floor scales them up automatically
(e.g. foreman_puma_workers up to 12, pulp_content_service_worker_count
up to 17 on an 8-core host) and OOMs on constrained development
environments. Pin them to small fixed values for the development
profile, the same way 6c79648 already pinned Candlepin's heap.

Set foreman_puma_workers, pulp_worker_count,
pulp_content_service_worker_count, and pulp_api_service_worker_count
all to 2, rather than deriving them from the pulp_worker_count*2+1 /
+1 formulas, since the development profile just needs to be as light
as possible.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@pablomh
pablomh force-pushed the reduce-dev-tuning-resources branch from ba0ea5e to 168e81e Compare October 8, 2026 12:51

@lzap lzap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it, RAM is not cheap today.

Would you mind also updating the RPM installation? I just witnessed 6 puma workers there too.

@lzap

lzap commented Oct 8, 2026

Copy link
Copy Markdown
Member

Ignore, I somewhat managed to copy-paste --tuning development from container installer to my test dev and it is silently ignored there :-)

@evgeni
evgeni merged commit 647887b into theforeman:master Oct 8, 2026
26 of 28 checks passed
@pablomh
pablomh deleted the reduce-dev-tuning-resources branch October 8, 2026 13:52
@pablomh

pablomh commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Love it, RAM is not cheap today.

Would you mind also updating the RPM installation? I just witnessed 6 puma workers there too.

Implemented in theforeman/foreman-installer#1070.

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.

3 participants