Skip to content

Commit

Permalink
Fixes #38085 - Cap the number of Puma workers at 100
Browse files Browse the repository at this point in the history
Users can easily run out of PostgreSQL connections on large deployments.
This provides a ceiling to the automatically calculated Puma workers
because it's unclear if that really provides performance benefits while
it can break deployments.

Not noticable here, but foreman-installer defaults to max 500 PostgreSQL
connections and has tuning options that to increase it to 1000.

Ideally it would be smarter, but it's really hard to account for all
possible conditions.
  • Loading branch information
ekohl committed Dec 13, 2024
1 parent 907b639 commit 0e8bb06
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,14 @@
content => epp('foreman/database.yml.epp', $db_context),
}

# Capped at 100 because worst case that's 100 * (5 + 4) = 900 PostgreSQL connections for Katello or 100 * 5 = 500 for vanilla Foreman
# CPU based calculation is based on https://github.com/puma/puma/blob/master/docs/deployment.md#mri
# Memory based calculation is based on https://docs.gitlab.com/ee/install/requirements.html#puma-settings
$puma_workers = pick(
$foreman::foreman_service_puma_workers,
floor(
min(
100,
$facts['processors']['count'] * 1.5,
($facts['memory']['system']['total_bytes']/(1024 * 1024 * 1024)) - 1.5
)
Expand Down

0 comments on commit 0e8bb06

Please sign in to comment.