-
-
Notifications
You must be signed in to change notification settings - Fork 257
Description
Describe the bug
Using the setting search.query.allowedSites = __all in a multi-site setup with many sites makes the search response and the auto-suggest very, very slow. I have 1 TYPO3 with 33 sites, and response times are between 5 and 15 seconds when using '__all'. If I set the value to all 33 domains, the response time < 1s.
I have debugged the issue and found that generating the list of domains is what takes up way too much time, I measured 5 to 12 seconds for these 33 sites. Additional problem is that this is done for every request, including every AJAX request for the auto-suggest feature.
Looking into the code (SiteHashService, SiteRepository), I found that an enormous amount of work is done of which in the end only the list of domains is used. What is even worse is that the result gets cached, but in a runtime cache which is empty at the next request, and because this method is only called once for each request, this caching only generates more overhead.
The core SiteFinder class can produce the same list of domains in less than 1 ms. Unless I missed something crucial that's being done in the complex current process I would propose to replace the method in SiteHashService (and further clean up that class):
<?php
....
protected function getDomainListOfAllSites(): string
{
$siteFinder = GeneralUtility::makeInstance(TYPO3\CMS\Core\Site\SiteFinder::class);
$sites = $siteFinder->getAllSites();
$domains = [];
foreach ($sites as $site) {
$domains[] = $site->getBase()->getHost();
}
return implode(',', $domains);
}To Reproduce
Steps to reproduce the behavior:
- Create a setup with many sites on different domains or subdomains
- set
plugin.tx_solr.search.query.allowedSites = __all - check how long it takes to for the search page or the auto-suggest to respond
- now try the same with all domains explicitly listed in allowedSites
You'll find a remarkable speed improvement with step 4.
Expected behavior
Using '__all' should not slow down the search or auto-suggest.
Used versions (please complete the following information):
- TYPO3 Version: [11.5.13]
- EXT:solr Version: [11.5.0-rc-2]
- Used Apache Solr Version: [8.11.1]
- PHP Version: [7.4.30]
- MariaDB Version: [10.3]
Possibly related to:
#2655