Skip to content

Commit 9c3b2e0

Browse files
committed
EXPERIMENT: Auto-tune PostgreSQL parameters
1 parent 92bb1cd commit 9c3b2e0

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

src/roles/postgresql/defaults/main.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ postgresql_data_dir: /var/lib/pgsql/data
99

1010
postgresql_admin_password: "CHANGEME"
1111

12-
postgresql_max_connections: 500
13-
postgresql_shared_buffers: 512MB
14-
postgresql_effective_cache_size: 1GB
12+
pulp_connections_count: "{{ pulp_worker_count + pulp_content_service_worker_count + pulp_api_service_worker_count }}"
13+
14+
postgresql_max_connections: "{{ ( pulp_connections_count | int + ( foreman_puma_workers | int * foreman_database_pool | int ) / 250 ) | round(0, 'ceil') | int * 250 }}"
15+
postgresql_shared_buffers: "{{ ( ansible_facts['memtotal_mb'] / 8192 ) | round(0, 'ceil') | int }}GB"
16+
postgresql_effective_cache_size: "{{ ( ansible_facts['memtotal_mb'] / 4096 ) | round(0, 'ceil') | int }}GB"

src/roles/pulp/defaults/main.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ pulp_api_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"
55
pulp_content_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"
66
pulp_worker_image: "{{ pulp_container_image }}:{{ pulp_container_tag }}"
77

8-
pulp_worker_count: "{{ [8, ansible_facts['processor_nproc']] | min }}"
9-
pulp_content_service_worker_count: "{{ (2 * ([8, ansible_facts['processor_nproc']] | min)) + 1 }}"
10-
pulp_api_service_worker_count: "{{ ([4, ansible_facts['processor_nproc']] | min) + 1 }}"
11-
128
pulp_volumes:
139
- /var/lib/pulp:/var/lib/pulp
1410

src/vars/defaults.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,20 @@ tuning_profile: development
55
flavor: katello
66
features: []
77
enabled_features: "{{ (flavor_features + features) }}"
8+
9+
pulp_worker_count: "{{ [8, ansible_facts['processor_nproc']] | min }}"
10+
pulp_content_service_worker_count: "{{ (2 * ([8, ansible_facts['processor_nproc']] | min)) + 1 }}"
11+
pulp_api_service_worker_count: "{{ ([4, ansible_facts['processor_nproc']] | min) + 1 }}"
12+
13+
# Puma threads calculation:
14+
# Max calculation is based on the default for MRI https://puma.io/puma6/#thread-pool
15+
# Min calculation is based on testing that showed that having the same value as the max led to
16+
# lower memory usage
17+
foreman_puma_threads_max: 5
18+
# Puma workers calculation:
19+
# CPU calculation is based on https://github.com/puma/puma/blob/master/docs/deployment.md#mri
20+
# Memory calculation is based on https://docs.gitlab.com/ee/install/requirements.html#puma-settings
21+
foreman_puma_workers: "{{ [ansible_facts['processor_nproc'] * 1.5, (ansible_facts['memtotal_mb'] / 1024) - 1.5] | min | int }}"
22+
23+
# Database pool calculation is based on https://community.theforeman.org/t/rails-connection-pool-size-optimizations/36675
24+
foreman_database_pool: "{{ foreman_puma_threads_max | int + 4 }}"

0 commit comments

Comments
 (0)