Skip to content

Commit 489a5da

Browse files
committed
EXPERIMENT: Auto-tune PostgreSQL parameters
1 parent 92bb1cd commit 489a5da

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

development/playbooks/remote-database/remote-database.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- database
55
become: true
66
vars_files:
7+
- "../../../src/vars/defaults.yml"
78
- "../../../src/vars/database.yml"
89
roles:
910
- role: pre_install

src/vars/defaults.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,34 @@ tuning_profile: development
55
flavor: katello
66
features: []
77
enabled_features: "{{ (flavor_features + features) }}"
8+
9+
# The number 25 is for the addition of:
10+
# - hibernate.c3p0.max_size: 20 (https://github.com/candlepin/candlepin/blob/main/src/main/resources/META-INF/persistence.xml#L20)
11+
# - org.quartz.dataSource.myDS.maxConnections: 5 (https://github.com/theforeman/puppet-candlepin/blob/master/templates/_candlepin_database.conf.epp#L36)
12+
candlepin_connection_count: 25
13+
14+
# Puma threads calculation:
15+
# Max calculation is based on the default for MRI https://puma.io/puma6/#thread-pool
16+
# Min calculation is based on testing that showed that having the same value as the max led to
17+
# lower memory usage
18+
foreman_puma_threads_max: 5
19+
# Puma workers calculation:
20+
# CPU calculation is based on https://github.com/puma/puma/blob/master/docs/deployment.md#mri
21+
# Memory calculation is based on https://docs.gitlab.com/ee/install/requirements.html#puma-settings
22+
foreman_puma_workers: "{{ [32, ansible_facts['processor_nproc'] * 1.5, (ansible_facts['memtotal_mb'] / 1024) - 1.5] | min | int }}"
23+
# Database pool calculation is based on https://community.theforeman.org/t/rails-connection-pool-size-optimizations/36675
24+
# The number 4 is for 4 threads that are spawned internally during the execution:
25+
# 1. Katello event daemon listener
26+
# 2. Katello event monitor poller
27+
# 3. Stomp listener (required by Katello)
28+
# 4. Puma server listener thread
29+
# This means for systems without Katello we can reduce the amount of the pool to foreman_puma_threads_max + 1
30+
foreman_database_pool: "{{ foreman_puma_threads_max | int + 4 }}"
31+
foreman_connection_count: "{{ foreman_puma_workers | int * foreman_database_pool | int }}"
32+
33+
pulp_worker_count: "{{ [8, ansible_facts['processor_nproc']] | min }}"
34+
pulp_content_service_worker_count: "{{ (2 * ([8, ansible_facts['processor_nproc']] | min)) + 1 }}"
35+
pulp_api_service_worker_count: "{{ ([4, ansible_facts['processor_nproc']] | min) + 1 }}"
36+
pulp_connection_count: "{{ pulp_worker_count | int + pulp_content_service_worker_count | int + pulp_api_service_worker_count | int }}"
37+
38+
postgresql_connection_count: "{{ candlepin_connection_count | int + foreman_connection_count | int + pulp_connection_count | int }}"

0 commit comments

Comments
 (0)