diff --git a/lib/puppet_x/puppetlabs/tune/calculate.rb b/lib/puppet_x/puppetlabs/tune/calculate.rb index 2011d91..84004de 100755 --- a/lib/puppet_x/puppetlabs/tune/calculate.rb +++ b/lib/puppet_x/puppetlabs/tune/calculate.rb @@ -43,6 +43,9 @@ def calculate_master_settings(node) minimum_cpu_puppetdb = 1 maximum_cpu_puppetdb = (node['resources']['cpu'] * 0.50).to_i + minimum_cpu_orchestrator = 1 + maximum_cpu_orchestrator = 4 + minimum_cpu_puppetserver = 2 maximum_cpu_puppetserver = 24 @@ -57,9 +60,6 @@ def calculate_master_settings(node) minimum_ram_code_cache = 96 maximum_ram_code_cache = 2048 - ram_per_jruby = fit_to_memory(node['resources']['ram'], 512, 768, 1024) - ram_per_jruby_code_cache = 96 - minimum_ram_database = 2048 maximum_ram_database = 16384 @@ -75,6 +75,9 @@ def calculate_master_settings(node) minimum_ram_activemq = 256 maximum_ram_activemq = 512 + ram_per_jruby = fit_to_memory(node['resources']['ram'], 512, 768, 1024) + ram_per_jruby_code_cache = 96 + cpu_reserved = 1 ram_reserved = select_reserved_memory(node['resources']['ram']) @@ -102,13 +105,6 @@ def calculate_master_settings(node) end end - # ORCH-2384: Orchestrator in PE 2019.2 has jrubies, and requires (estimated) one processor and additional memory. - # Reallocate the processor associated with one jruby from puppetserver to orchestrator. - - if node['classes']['orchestrator'] && node['type']['with_orchestrator_jruby'] - cpu_reserved += 1 - end - # The Vegas Renormalization: allow for testing with vmpooler (2 CPU / 6 GB RAM) VMs. if node['resources']['cpu'] < 3 @@ -135,7 +131,6 @@ def calculate_master_settings(node) if node['classes']['puppetdb'] # Reallocate resources between puppetserver and puppetdb, if this host is a compiler (puppetserver plus puppetdb). - if node['type']['is_compile_master'] || node['type']['is_compiler'] percent_cpu_puppetdb = 0.25 minimum_cpu_puppetdb = 1 @@ -152,16 +147,22 @@ def calculate_master_settings(node) end if node['classes']['orchestrator'] - ram_orchestrator = (node['resources']['ram'] * percent_ram_orchestrator).to_i.clamp(minimum_ram_orchestrator, maximum_ram_orchestrator) if node['type']['with_orchestrator_jruby'] - # ORCH-2384 - ram_orchestrator += ram_per_jruby + ram_per_jruby_code_cache - orchestrator_jruby_max_active_instances = 2 - # ram_orchestrator_code_cache = orchestrator_jruby_max_active_instances * ram_per_jruby_code_cache + # Reallocate resources between orchestrator and puppetserver, if orchestrator has jrubies. + percent_ram_orchestrator = 0.10 + + # Note: orchestrator_jruby_max_active_instances is constrained based on how many jrubies fit into orchestrator memory. + ram_orchestrator = [(node['resources']['ram'] * percent_ram_orchestrator).to_i, minimum_ram_orchestrator].max + max_jrubies_in_ram_orchestrator = (ram_orchestrator / ram_per_jruby).to_i + orchestrator_jruby_max_active_instances = max_jrubies_in_ram_orchestrator.clamp(minimum_cpu_orchestrator, maximum_cpu_orchestrator) settings['params']['puppet_enterprise::profile::orchestrator::jruby_max_active_instances'] = orchestrator_jruby_max_active_instances # Note: orchestrator_jruby_max_active_instances is not a dedicated allocation, do not add it to settings['totals']['CPU']['used']. + + # ram_orchestrator_code_cache = orchestrator_jruby_max_active_instances * ram_per_jruby_code_cache # settings['params']['puppet_enterprise::profile::orchestrator::reserved_code_cache'] = ram_orchestrator_code_cache # settings['totals']['RAM']['used'] += ram_orchestrator_code_cache + else + ram_orchestrator = (node['resources']['ram'] * percent_ram_orchestrator).to_i.clamp(minimum_ram_orchestrator, maximum_ram_orchestrator) end settings['params']['puppet_enterprise::profile::orchestrator::java_args'] = { 'Xms' => "#{ram_orchestrator}m", 'Xmx' => "#{ram_orchestrator}m" } settings['totals']['RAM']['used'] += ram_orchestrator @@ -187,7 +188,7 @@ def calculate_master_settings(node) return end - # Note: jruby_max_active_instances is constrained based on both how many jrubies fit into unallocated memory and unallocated processors. + # Note: puppetserver_jruby_max_active_instances is constrained based on both how many jrubies fit into unallocated memory and unallocated processors. maximum_cpu_puppetserver = (node['resources']['cpu'] - cpu_reserved - settings['totals']['CPU']['used']).clamp(minimum_cpu_puppetserver, maximum_cpu_puppetserver) max_jrubies_in_ram_puppetserver = (ram_puppetserver / (ram_per_jruby + ram_per_jruby_code_cache)).to_i diff --git a/spec/unit/puppet_x/puppetlabs/tune/calculate_spec.rb b/spec/unit/puppet_x/puppetlabs/tune/calculate_spec.rb index c97e3d5..3283eb0 100644 --- a/spec/unit/puppet_x/puppetlabs/tune/calculate_spec.rb +++ b/spec/unit/puppet_x/puppetlabs/tune/calculate_spec.rb @@ -9,23 +9,20 @@ # Allows mergeups in the PE implementation of this class. pe_2019_or_newer = Gem::Version.new(Puppet.version) >= Gem::Version.new('6.0.0') - ram_per_jruby_code_cache = 96 - - percent_ram_database = 0.25 - percent_ram_puppetdb = 0.10 - percent_ram_console = 0.08 - percent_ram_orchestrator = 0.08 - percent_ram_activemq = 0.08 - - percent_ram_puppetdb_with_compilers = 0.15 - percent_ram_puppetdb_split = 0.25 - percent_ram_puppetdb_split_external = 0.50 + percent_cpu_puppetdb = 0.25 + percent_cpu_puppetdb_with_compilers = 0.50 + + percent_ram_database = 0.25 + percent_ram_puppetdb = 0.10 + percent_ram_puppetdb_with_compilers = 0.15 + percent_ram_puppetdb_split = 0.25 + percent_ram_puppetdb_split_external = 0.50 + percent_ram_orchestrator = 0.08 + percent_ram_orchestrator_with_jrubies = 0.10 + percent_ram_console = 0.08 + percent_ram_activemq = 0.08 minimum_ram_database = 2048 - # maximum_ram_database = 16384 - - # minimum_ram_puppetdb = 512 - # maximum_ram_puppetdb = 8192 minimum_ram_puppetserver = 512 @@ -38,6 +35,8 @@ minimum_ram_activemq = 256 maximum_ram_activemq = 512 + ram_per_jruby_code_cache = 96 + context 'with a monolithic infrastructure' do it 'can calculate master host settings, in vmpooler' do resources = { @@ -132,7 +131,7 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 1 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb).to_i cpu_puppetserver = 2 ram_per_jruby = 512 ram_database = minimum_ram_database @@ -201,7 +200,7 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 2 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb).to_i cpu_puppetserver = 5 ram_per_jruby = 768 ram_database = (resources['ram'] * percent_ram_database).to_i @@ -270,7 +269,7 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 4 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb).to_i cpu_puppetserver = 11 ram_per_jruby = 1024 ram_database = (resources['ram'] * percent_ram_database).to_i @@ -339,18 +338,17 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 4 - cpu_puppetserver = 10 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb).to_i + cpu_puppetserver = 9 ram_per_jruby = 1024 ram_database = (resources['ram'] * percent_ram_database).to_i ram_puppetdb = (resources['ram'] * percent_ram_puppetdb).to_i + ram_orchestrator = (resources['ram'] * percent_ram_orchestrator_with_jrubies).to_i ram_puppetserver = cpu_puppetserver * ram_per_jruby ram_puppetserver_cc = cpu_puppetserver * ram_per_jruby_code_cache - ram_orchestrator = maximum_ram_orchestrator + ram_per_jruby + ram_per_jruby_code_cache ram_console = maximum_ram_console - # ORCH-2384 - cpu_orchestrator = 2 + cpu_orchestrator = 3 # ram_orchestrator_cc = cpu_orchestrator * ram_per_jruby_code_cache params = { @@ -404,7 +402,7 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 2 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb_with_compilers).to_i cpu_puppetserver = 2 ram_per_jruby = 512 ram_database = minimum_ram_database @@ -473,7 +471,7 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 2 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb_with_compilers).to_i cpu_puppetserver = 2 ram_per_jruby = 512 ram_database = 0 @@ -524,7 +522,7 @@ } infrastructure = { 'is_monolithic' => true, - 'with_compile_masters' => false, + 'with_compile_masters' => true, 'compiler_connections' => 500, } type = { @@ -542,11 +540,11 @@ } node = { 'resources' => resources, 'infrastructure' => infrastructure, 'type' => type, 'classes' => classes } - cpu_puppetdb = 1 + cpu_puppetdb = (resources['cpu'] * percent_cpu_puppetdb_with_compilers).to_i cpu_puppetserver = 2 ram_per_jruby = 512 ram_database = minimum_ram_database - ram_puppetdb = (resources['ram'] * percent_ram_puppetdb).to_i + ram_puppetdb = (resources['ram'] * percent_ram_puppetdb_with_compilers).to_i ram_puppetserver = cpu_puppetserver * ram_per_jruby ram_orchestrator = (resources['ram'] * percent_ram_orchestrator).to_i ram_console = (resources['ram'] * percent_ram_console).to_i