Drupal Version

Drupal 9

Domain module version

8.x-1.0-beta6

Expected Behavior

The number of request while loading a page after a cache clear should be increased only by the number of existing configuration overrides.

Actual Behavior

On a Drupal 8 project using Redis, after a cache flush, the total number of requests sent to the database to display a page was about 1000 requests of which about half were related to Domain Config and more precisely to DomainConfigOverrider::loadOverrides().

After the switch to Drupal 9, this number of requests after a cache clear increases to 3000 and DomainConfigOverrider::loadOverrides() triggers 2500 requests out of these 3000.

From what I understand, the problem is that in version D8 Domain Config only made a request to retrieve a config override if it actually existed.

After the switch to D9, Domain Config makes a request for all the configurations of the site.

For information I tested version 1.0-beta6 on Drupal 8 and I have 1000 requests and with the same version on Drupal 9 I have 3000 requests.
So certainly something has changed in the core of Drupal between version 8 and version 9 that explains this behavior.

Steps to reproduce

Here the steps on a fresh install without using Redis for a more easy way to reproduce :

  • Install Drupal without Domain Config
  • Clear all cache
  • Display a page
  • Using a tool like xhprof see that the number of request is ~1659
  • Enable domain config and domain config ui
  • Create a domain
  • Go to Configuration > System > Basic site settings
  • and override the configuration for the domain created above

  • Clear all cache
  • Display a page
  • See that the number of requests is now ~2700

I also attached a screenshot of comparison using xhprof.

Proposed resolution

Check that the configuration override exists before to request the database to load it.

Comments

Nixou created an issue. See original summary.

nixou’s picture

Title: Significant increase in requests following the switch to drupal 9 » Significant database request increase following the switch to drupal 9
nixou’s picture

Issue summary: View changes
nixou’s picture

Status: Active » Needs review
StatusFileSize
new2.72 KB
nixou’s picture

Issue summary: View changes
StatusFileSize
new468.55 KB
nixou’s picture

Issue summary: View changes
nixou’s picture

Issue summary: View changes
nixou’s picture

Issue summary: View changes
nixou’s picture

Issue summary: View changes
nixou’s picture

Issue summary: View changes
nixou’s picture

StatusFileSize
new1.55 KB
new2.61 KB
nixou’s picture

StatusFileSize
new1.21 KB
new876 bytes
nixou’s picture

Tests ok against 9.2.x (since Domain Source is not compatible with Drupal 9.3 but not relevant to this issue).

Some additional metrics on Drupal 9.3.9 - Fresh install - Minimal profile - Homepage display after clear cache :

Without Redis

  • DB request number without Domain Config : 281
  • DB request number with Domain Config + Override basic site settings : 426
  • DB request number with Domain Config + Override basic site settings + this patch : 274

With Redis

  • DB request number without Domain Config : 60
  • DB request number with Domain Config + Override basic site settings : 94
  • DB request number with Domain Config + Override basic site settings + this patch : 60
agentrickard’s picture

Nice.

We do like to use the `true` flag on `in_array`.

e.g.

if (in_array($config_name['langcode'], $this->storage->listAll('domain.config.', TRUE))

https://www.php.net/manual/en/function.in-array.php

agentrickard’s picture

StatusFileSize
new1.5 KB

Minor update.

agentrickard’s picture

Version: 8.x-1.0-beta6 » 8.x-1.x-dev

  • agentrickard committed 0d31811 on 8.x-1.x authored by Nixou
    Issue #3272841 by Nixou, agentrickard: Significant database request...
agentrickard’s picture

Category: Bug report » Task
Status: Needs review » Fixed

Committed! (Though not really a bug,)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.