Auto discovery/provision fails and make entire foreman instance unresponsive

Problem:
When we have more servers from one provision doing auto discovery Foreman got stucked. In logs I can see a lot of messages like:

2021-03-05T18:39:00 [I|app|411b38ab] Locking discovered host 3c:ec:ef:22:fb:9f in subnet internal provisioning subnet SGP via pxegrub
_discovery template
2021-03-05T18:39:00 [W|app|411b38ab] Could not find a provider for mac-3cecef22fb9f. Providers returned {"MediumProviders::Default"=>
["Operating system was not set for host 'mac-3cecef22fb9f'", " medium was not set for host 'mac-3cecef22fb9f'", "Invalid medium '' fo
r ''", "Invalid architecture '' for ''"]}
2021-03-05T18:39:00 [I|app|2dcdce32] Locking discovered host 3c:ec:ef:21:e1:15 in subnet internal provisioning subnet SGP via  templa
te
2021-03-05T18:39:00 [W|app|2dcdce32] Template '' provided by setting 'discovery_ipxe_lock_template' does not exist, not locking
2021-03-05T18:39:00 [I|app|411b38ab] Locking discovered host 3c:ec:ef:22:fb:9f in subnet internal provisioning subnet SGP via  templa
te
2021-03-05T18:39:00 [W|app|411b38ab] Template '' provided by setting 'discovery_ipxe_lock_template' does not exist, not locking
2021-03-05T18:39:01 [I|app|2dcdce32] Match found for host mac-3cecef21e115 (12532) rule SGP (30)
2021-03-05T18:39:01 [W|app|2dcdce32] Could not find a provider for mac-3cecef21e115. Providers returned {"MediumProviders::Default"=>
["Operating system was not set for host 'mac-3cecef21e115'", " medium was not set for host 'mac-3cecef21e115'", "Invalid medium '' fo
r ''", "Invalid architecture '' for ''"]}
2021-03-05T18:39:01 [I|app|411b38ab] Match found for host mac-3cecef22fb9f (12568) rule SGP (30)
2021-03-05T18:39:01 [W|app|411b38ab] Could not find a provider for mac-3cecef22fb9f. Providers returned {"MediumProviders::Default"=>
["Operating system was not set for host 'mac-3cecef22fb9f'", " medium was not set for host 'mac-3cecef22fb9f'", "Invalid medium '' fo
r ''", "Invalid architecture '' for ''"]}
2021-03-05T18:39:15 [W|app|f1d170ed] Not queueing Host::Managed: ["Name has already been taken"]
2021-03-05T18:39:15 [W|app|f1d170ed] Not queueing Host::Managed: ["Name has already been taken"]
2021-03-05T18:39:15 [W|app|f1d170ed] Not queueing Host::Managed: ["Name has already been taken"]
2021-03-05T18:39:15 [W|app|f1d170ed] Not queueing Discovery reboot: Name has already been taken
2021-03-05T18:39:15 [E|app|f1d170ed] Auto provisioning failed: Name has already been taken

Expected outcome:
That new servers are autoprovision. And if there is no luck it does not effect whole foreman instance, which doesn’t respond over web GUI or even to hammer commands.

Foreman and Proxy versions:
Master - 2.2.2
Proxies - 2.2.3

Foreman and Proxy plugin versions:
master foreman_discovery - 16.1.2
proxy discovery - 1.0.3
Distribution and version:
Debian 10
Other relevant data:

 | /usr/share/foreman/app/controllers/api/base_controller.rb:147:in `process_resource_error'
 | /usr/share/foreman/app/controllers/api/base_controller.rb:167:in `process_response'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/foreman_discovery-16.1.2/app/controllers/api/v2/discovered_hosts_controller.rb:110:in `f
acts'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_actio
n'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb:195:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/rendering.rb:30:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb:42:in `block in process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:112:in `block in run_callbacks'
 | /usr/share/foreman/app/controllers/api/v2/base_controller.rb:181:in `disable_json_root'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/app/controllers/concerns/foreman/controller/timezone.rb:10:in `set_timezone'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/app/models/concerns/foreman/thread_session.rb:32:in `clear_thread'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/app/controllers/concerns/foreman/controller/topbar_sweeper.rb:12:in `set_topbar_sweeper_controller'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/audited-4.9.0/lib/audited/sweeper.rb:14:in `around'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:139:in `run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/callbacks.rb:41:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/rescue.rb:22:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `block in instrument'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/notifications.rb:180:in `instrument'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/instrumentation.rb:32:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activerecord-6.0.3.4/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/abstract_controller/base.rb:136:in `process'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionview-6.0.3.4/lib/action_view/rendering.rb:39:in `process'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb:190:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_controller/metal.rb:254:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:33:in `serve'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/mapper.rb:18:in `block in <class:Constraints>'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/mapper.rb:48:in `serve'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:49:in `block in serve'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:32:in `each'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/journey/router.rb:32:in `serve'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/routing/route_set.rb:834:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/apipie-dsl-2.3.0/lib/apipie_dsl/static_dispatcher.rb:67:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/apipie-rails-0.5.18/lib/apipie/static_dispatcher.rb:66:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/apipie-rails-0.5.18/lib/apipie/extractor/recorder.rb:137:in `call'
 | /usr/share/foreman/lib/foreman/middleware/telemetry.rb:10:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/apipie-rails-0.5.18/lib/apipie/middleware/checksum_in_headers.rb:27:in `call'
 | /usr/share/foreman/lib/foreman/middleware/catch_json_parse_errors.rb:9:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/tempfile_reaper.rb:15:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/etag.rb:27:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/conditional_get.rb:40:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/http/content_security_policy.rb:18:in `call'
 | /usr/share/foreman/lib/foreman/middleware/logging_context_session.rb:22:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:266:in `context'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/session/abstract/id.rb:260:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/cookies.rb:648:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/callbacks.rb:101:in `run_callbacks'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/callbacks.rb:26:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:37:in `call_app'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.4/lib/rails/rack/logger.rb:28:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/sprockets-rails-3.2.2/lib/sprockets/rails/quiet_assets.rb:13:in `call'
 | /usr/share/foreman/lib/foreman/middleware/logging_context_request.rb:11:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/request_id.rb:27:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/runtime.rb:22:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/activesupport-6.0.3.4/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/executor.rb:14:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/static.rb:126:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/actionpack-6.0.3.4/lib/action_dispatch/middleware/host_authorization.rb:76:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/secure_headers-6.3.1/lib/secure_headers/middleware.rb:11:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.4/lib/rails/engine.rb:527:in `call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.4/lib/rails/railtie.rb:190:in `public_send'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/railties-6.0.3.4/lib/rails/railtie.rb:190:in `method_missing'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
 | /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:107:in `process_request'
 | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:157:in `accept_and_process_next_request'
 | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
 | /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
 | /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
 | /usr/share/foreman/vendor/ruby/2.5.0/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
2021-03-05T18:39:15 [I|app|f1d170ed] Completed 422 Unprocessable Entity in 60241ms (Views: 0.2ms | ActiveRecord: 9547.6ms | Allocations: 29898076)
2021-03-05T18:39:15 [I|app|4ece9351] Started POST "/api/v2/discovered_hosts/facts" for 89.187.162.3 at 2021-03-05 18:39:15 +0000
2021-03-05T18:39:15 [I|app|4ece9351] Processing by Api::V2::DiscoveredHostsController#facts as JSON
2021-03-05T18:39:15 [I|app|4ece9351]   Parameters: {"facts"=>"[FILTERED]", "apiv"=>"v2", "discovered_host"=>{"facts"=>"[FILTERED]"}}
2021-03-05T18:39:15 [W|app|4ece9351] One or more existing managed hosts found: mac-3cecef21e2cb.10gbps.io/3c:ec:ef:21:e2:cb
2021-03-05T18:39:15 [I|app|4ece9351] Import facts for 'mac-3cecef21e2cb' completed. Added: 0, Updated: 0, Deleted 0 facts
2021-03-05T18:39:15 [I|app|4ece9351] Detected IPv4 subnet: internal provisioning subnet SGP with taxonomy ["Default Organization", "d
p_test"]/["Default Location"]
2021-03-05T18:39:15 [I|app|4ece9351] Assigned location: Default Location
2021-03-05T18:39:15 [I|app|4ece9351] Assigned organization: Default Organization
2021-03-05T18:39:16 [I|app|4ece9351] Locking discovered host 3c:ec:ef:21:e2:cb in subnet internal provisioning subnet SGP via pxegrub
2_discovery template
2021-03-05T18:39:16 [W|app|4ece9351] Could not find a provider for mac-3cecef21e2cb. Providers returned {"MediumProviders::Default"=>
["Operating system was not set for host 'mac-3cecef21e2cb'", " medium was not set for host 'mac-3cecef21e2cb'", "Invalid medium '' fo
r ''", "Invalid architecture '' for ''"]}
2021-03-05T18:39:16 [I|app|4ece9351] Locking discovered host 3c:ec:ef:21:e2:cb in subnet internal provisioning subnet SGP via PXELinu
x default discovery template
2021-03-05T18:39:16 [W|app|4ece9351] Could not find a provider for mac-3cecef21e2cb. Providers returned {"MediumProviders::Default"=>
["Operating system was not set for host 'mac-3cecef21e2cb'", " medium was not set for host 'mac-3cecef21e2cb'", "Invalid medium '' fo
r ''", "Invalid architecture '' for ''"]}

On proxy there are frequently repeating logs like:

021-03-05T18:39:16 4ece9351 [I] Started POST /tftp/PXEGrub2/3c:ec:ef:21:e2:cb  
2021-03-05T18:39:16 4ece9351 [I] Finished POST /tftp/PXEGrub2/3c:ec:ef:21:e2:cb with 200 (0.88 ms)
2021-03-05T18:39:17 4ece9351 [I] Started POST /tftp/PXELinux/3c:ec:ef:21:e2:cb  
2021-03-05T18:39:17 4ece9351 [I] Finished POST /tftp/PXELinux/3c:ec:ef:21:e2:cb with 200 (0.98 ms)
2021-03-05T18:39:18 4ece9351 [I] Started POST /tftp/PXEGrub/3c:ec:ef:21:e2:cb  
2021-03-05T18:39:18 4ece9351 [I] Finished POST /tftp/PXEGrub/3c:ec:ef:21:e2:cb with 200 (0.87 ms)```

This looks like there already is a host with this MAC address either managed or discovered in a different organization. Try to change to Any Organization and delete it.

To resolve stucked foreman master, I had to restart it and quickly disable auto-provisioning. Then I removed all discovered hosts and enabled auto-provisioning once again.
Server was completely unresponsive. Here you can see aggregated graph of CPU when this happend.

Logs I posted are just examples. There was much more unprovisioned hosts in loop.
We are using one organisation in Foreman.
This happened already second time after we upgraded to 2.2 version. Is there anything you advice to do to avoid this situations?

Investing what endpoints were slow in production.log, reporting it here so we can take a look.

Part from production log, which I putted here, is one which was repeating during outage. I don’t think there was anything else.

How can I say which endpoints were slow?

Foreman provides telemetry capability, but the Prometheus client is buggy, you can use statsd protocol to catch those measurements.

Alternatively there’s a script that parses production.log: GitHub - pmoravec/rails-load-stats: A script parsing a logfile of a Ruby on Rails app to analyze where the load to the app comes from.

Today I have again issue with discovery. Looks to me that server is added to hosts but even so stays between discovered. And after reboot it does again discovery. And then there are errors

[E|app|1b010cd0] Auto provisioning failed: Name has already been taken

Here is analyze.sh output for our production log:

Mon Mar 15 16:02:39 UTC 2021: extracting relevant data from input file '/var/log/foreman/production.log'..
Mon Mar 15 16:02:39 UTC 2021: processing the extracted data (this can take a while)..
Mon Mar 15 16:02:40 UTC 2021: summarizing stats..

there were 3550 requests taking 7544875 ms (i.e. 2.10 hours, i.e. 0.09 days) in summary

type                                            count   min     max     avg     mean    sum             percentage
--------------------------------------------------------------------------------------------------------------------
DashboardController#index                       192     162     247     180     177     34672           0.46 %
DiscoveredHostsController#destroy               159     299     531     342     336     54498           0.72 %
DiscoveredHostsController#facts                 112     1690    109445  60171   89198   6739190         89.32 %
DiscoveredHostsController#index                 24      269     1316    494     292     11860           0.16 %
HostgroupsController#index                      19      145     222     167     160     3176            0.04 %
HostsController#destroy                         21      526     4943    1902    1812    39955           0.53 %
HostsController#index                           196     123     500     150     135     29454           0.39 %
HostsController#show                            885     120     345     193     191     171246          2.27 %
HostsController#update                          95      242     5919    1346    807     127912          1.70 %
InterfacesController#create                     8       153     240     171     164     1374            0.02 %
MediaController#index                           19      121     198     131     127     2502            0.03 %
SubnetsController#index                         89      167     3088    1238    1355    110252          1.46 %
SubnetsController#update                        2       191     199     195     191     390             0.01 %
AuditsController#index                          1       1374    1374    1374    1374    1374            0.02 %
DashboardController#index                       34      2       46      35      34      1194            0.02 %
DashboardController#show                        136     29      1781    149     48      20300           0.27 %
DiscoveredHostsController#auto_complete_search  27      9       37      24      30      674             0.01 %
DiscoveredHostsController#destroy               5       213     312     257     247     1286            0.02 %
DiscoveredHostsController#index                 20      82      373     176     123     3538            0.05 %
DiscoveredHostsController#show                  8       78      102     87      85      701             0.01 %
DiscoveryRulesController#edit                   3       79      97      89      91      267             0.00 %
DiscoveryRulesController#index                  7       196     249     221     224     1551            0.02 %
DiscoveryRulesController#new                    1       60      60      60      60      60              0.00 %
DiscoveryRulesController#update                 1       55      55      55      55      55              0.00 %
HostgroupsController#edit                       1       829     829     829     829     829             0.01 %
HostgroupsController#index                      2       266     268     267     266     534             0.01 %
HostgroupsController#medium_selected            1       23      23      23      23      23              0.00 %
HostgroupsController#update                     1       231     231     231     231     231             0.00 %
HostsController#auto_complete_search            44      9       43      13      12      581             0.01 %
HostsController#bmc                             1       45      45      45      45      45              0.00 %
HostsController#cancelBuild                     2       1847    1872    1859    1847    3719            0.05 %
HostsController#current_parameters              1       71      71      71      71      71              0.00 %
HostsController#destroy                         5       1773    1837    1802    1800    9012            0.12 %
HostsController#edit                            9       2849    3674    3170    3065    28536           0.38 %
HostsController#index                           19      78      306     159     113     3026            0.04 %
HostsController#medium_selected                 1       19      19      19      19      19              0.00 %
HostsController#nics                            24      38      86      53      51      1287            0.02 %
HostsController#os_selected                     1       63      63      63      63      63              0.00 %
HostsController#overview                        24      33      110     48      44      1171            0.02 %
HostsController#puppetclass_parameters          1       53      53      53      53      53              0.00 %
HostsController#resources                       24      14      73      24      18      584             0.01 %
HostsController#review_before_build             1       696     696     696     696     696             0.01 %
HostsController#runtime                         24      13      66      23      21      572             0.01 %
HostsController#setBuild                        1       1396    1396    1396    1396    1396            0.02 %
HostsController#show                            27      1       161     62      60      1698            0.02 %
HostsController#templates                       24      119     208     142     140     3412            0.05 %
HostsController#update                          3       147     1468    631     278     1893            0.03 %
NotificationRecipientsController#index          1119    6       77      8       8       9491            0.13 %
ReactController#index                           1       28      28      28      28      28              0.00 %
SmartProxiesController#errors_card              2       23      741     382     23      764             0.01 %
SmartProxiesController#failed_modules           2       37      709     373     37      746             0.01 %
SmartProxiesController#index                    2       163     164     163     163     327             0.00 %
SmartProxiesController#log_pane                 2       21      1453    737     21      1474            0.02 %
SmartProxiesController#modules_card             2       24      713     368     24      737             0.01 %
SmartProxiesController#ping                     42      15      1110    175     22      7388            0.10 %
SmartProxiesController#refresh                  1       26      26      26      26      26              0.00 %
SmartProxiesController#show                     2       191     200     195     191     391             0.01 %
SmartProxiesController#tftp_server              2       32      393     212     32      425             0.01 %
SubnetsController#auto_complete_search          8       9       19      12      11      96              0.00 %
SubnetsController#edit                          1       201     201     201     201     201             0.00 %
SubnetsController#freeip                        1       88882   88882   88882   88882   88882           1.18 %
SubnetsController#index                         3       113     189     146     137     439             0.01 %
UnattendedController#built                      14      498     2336    956     657     13395           0.18 %
UnattendedController#host_template              37      55      155     80      76      2987            0.04 %
UsersController#login                           4       5       67      36      7       146             0.00 %

It looks you must have some server(s) with many facts which cause performance issues. We have seen servers with thousand of drives causing problems in the past. Can you investigate those slow nodes? Enable ssh, connect and then pastebin output of “facter --json” command.