Skip to content

High number of parallel DB connections when opening Business Process Dashboard #485

@ngoeddel-openi

Description

@ngoeddel-openi

Describe the bug

When opening the Business Process Dashboard, the code triggers an apply() call for every defined business process. Each call runs complex SQL SELECT queries against the IcingaDB instance.

With a larger number of business processes (or processes referencing many hosts/services), this results in a linearly increasing number of parallel connections to the IcingaDB database.
In our environment, this frequently causes us to hit the max_connections limit on the MariaDB instance.

Analysis

Excerpt from library/Businessprocess/Web/Component/Dashboard.php::

foreach ($processes as $name) {
    if (Module::exists('icingadb') &&
        (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
    ) {
        IcingaDbState::apply($bp);
    } else {
        MonitoringState::apply($bp);
    }
}

Inside IcingaDbState::apply(), yieldAll() is used to fetch service and host data from IcingaDB:

foreach ($this->backend->yieldAll($services->assembleSelect()) as $row) { ... }
foreach ($this->backend->yieldAll($hosts->assembleSelect()) as $row) { ... }

It appears that a new query (and connection) is opened for each configured process. Additionally, Redis lookups are performed for fresh state data but do not replace the database queries — they are executed in parallel.

Impact

  • Parallel DB connections grow linearly with the number of processes.
  • Short-lived spikes in Threads_connected can cause performance degradation or even connection errors when max_connections is reached.
  • Particularly problematic in distributed setups or when no connection pooling is in place.

To Reproduce

  1. Define multiple business processes (e.g., 50+).
  2. Open the Business Processes dashboard in IcingaWeb.
  3. Monitor the DB connections — the number of active connections spikes sharply.

Expected behavior

  • Reuse existing DB connections (pooling) or process items sequentially to avoid spikes.
  • Optionally allow configuration of a maximum parallelism threshold for queries.

Workarounds

  • Increase max_connections in MariaDB.
  • Use a connection pooler like ProxySQL or MariaDB MaxScale.
  • Reduce dashboard refreshes during high-traffic periods.

Screenshots

This is what I see when running SHOW FULL PROCESSLIST; at the right time:

Image

Your Environment

Include as many relevant details about the environment you experienced the problem in

  • Icinga Web 2 version and modules (System - About): 2.12.4
  • Web browser used: Chrome
  • Icinga 2 version used (icinga2 --version): 2.14.5-1
  • PHP version used (php --version): 8.2.28
  • Server operating system and version: RHEL9

Additional context

Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions