Cap the number of worker threads

Users can configure the number of worker threads however when it's
not specified the calculated number of workers can get too large on
hosts with a large number of CPUs.

Change-Id: Ic0c77d03ab67d3850fa6b46010e63d886a96cc31
This commit is contained in:
Ravi Gummadi 2017-03-01 07:37:45 -05:00
parent 2f68deee89
commit 5b9ce0b551
3 changed files with 16 additions and 11 deletions

View File

@ -71,7 +71,9 @@ galera_innodb_log_buffer_size: 128M
galera_wsrep_address: "{{ ansible_host }}"
galera_wsrep_cluster_address: "{% if galera_cluster_members | length > 1 %}{% for host in galera_cluster_members %}{{ hostvars[host]['ansible_host'] }}{% if not loop.last %},{% endif %}{% endfor %}{% endif %}"
galera_wsrep_node_incoming_address: "{{ galera_wsrep_address }}"
galera_wsrep_slave_threads: "{{ (ansible_processor_vcpus | int > 0) | ternary (ansible_processor_vcpus, 2) }}"
## Cap the maximum number of threads / workers when a user value is unspecified.
galera_wsrep_slave_threads_max: 16
galera_wsrep_slave_threads: "{{ [[ansible_processor_vcpus|default(2), 2] | max, galera_wsrep_slave_threads_max] | min }}"
galera_wsrep_retry_autocommit: 3
galera_wsrep_debug: 0
galera_wsrep_sst_method: xtrabackup-v2
@ -99,9 +101,9 @@ galera_cluster_cnf_overrides: {}
galera_debian_cnf_overrides: {}
# Set the max connections value for galera. Set this value to override the
# computed value which is (100 x vCPUs). If computed, the lowest value throughout
# the cluster will be used which is something to note if deploying galera on different
# hardware.
# computed value which is (100 x vCPUs) with a cap of 1600. If computed, the
# lowest value throughout the cluster will be used which is something to note
# if deploying galera on different hardware.
# galera_max_connections: 500
# Settings for percona and qpress

View File

@ -1,7 +1,7 @@
{%- set all_calculated_max_connections = [] %}
{%- for galera_node in galera_cluster_members %}
{%- set vcpus = hostvars[galera_node]['ansible_processor_vcpus'] %}
{%- if all_calculated_max_connections.append((vcpus | int > 0) | ternary (vcpus, 2) * 100) %}
{%- if all_calculated_max_connections.append([[vcpus|default(2), 2] | max, galera_wsrep_slave_threads_max] | min * 100) %}
{%- endif %}
{%- endfor %}
{%- set calculated_max_connections = all_calculated_max_connections|sort %}
@ -49,11 +49,14 @@ log_bin_trust_function_creators = 1
max-allowed-packet = 16M
max-connect-errors = 1000000
# NOTE: The number of max connections is defined by ( host_vcpus * 100 ). This value
# is the lowest integer based on the ansible facts gathered from every galera node.
# Computing the connections value using the lowest denominator maintains cluster integrity
# by not attempting to over commit to a less capable machine.
# These are the computed max_connections based on cluster data {{ calculated_max_connections }}
# NOTE: If galera_max_connections is not configured by user, the number of max
# connections is defined by ( host_vcpus * 100 ) with a capping value of 1600.
# This value is the lowest integer based on the ansible facts gathered from
# every galera node.
# Computing the connections value using the lowest denominator maintains
# cluster integrity by not attempting to over commit to a less capable machine.
# These are the computed max_connections based on the cluster data
# {{ calculated_max_connections }}
max_connections = {{ galera_max_connections | default(calculated_max_connections[0]) }}
wait_timeout = {{ galera_wait_timeout }}

View File

@ -3,7 +3,7 @@
{%- set all_calculated_max_connections = [] %}
{%- for galera_node in galera_cluster_members %}
{%- set vcpus = hostvars[galera_node]['ansible_processor_vcpus'] %}
{%- set _ = all_calculated_max_connections.append((vcpus | int > 0) | ternary (vcpus, 2) * 100) %}
{%- set _ = all_calculated_max_connections.append([[vcpus|default(2), 2] | max, galera_wsrep_slave_threads_max] | min * 100) %}
{%- endfor %}
{%- set calculated_min_connections = all_calculated_max_connections | min %}
{%- set calculated_max_connections = galera_max_connections | default(calculated_min_connections) %}