Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caching: high database usage after cache cleanup #4531

Closed
giannello opened this issue Jun 17, 2019 · 0 comments

Comments

Projects
3 participants
@giannello
Copy link

commented Jun 17, 2019

When the redirect cache is invalidated (either from the admin panel, or via CLI), or it expires (default to 28 days), it gets automatically re-populated with the next http request.

If the redirects list is big enough (~14k entries here), and the website serves enough traffic, this creates a cache stampede effect, where each http request tries to warm the redirect cache, creating a peak of queries on the database:

image

The relevant code is

if (!($this->redirects = Cache::load($cacheKey))) {
$list = new Redirect\Listing();
$list->setCondition('active = 1');
$list->setOrder('DESC');
$list->setOrderKey('priority');
$this->redirects = $list->load();
Cache::save($this->redirects, $cacheKey, ['system', 'redirect', 'route'], null, 998);
}

Adding a mutex would help the stability of the system.

@giannello giannello changed the title Caching: excessive database usage after cache cleanup Caching: high database usage after cache cleanup Jun 17, 2019

@dvesh3 dvesh3 added the Improvement label Jun 19, 2019

@dvesh3 dvesh3 added this to To do in 13/06/2019 - 28/06/2019 via automation Jun 19, 2019

@dvesh3 dvesh3 added this to the 6.0.1 ("Flanders Red Ale") milestone Jun 19, 2019

@brusch brusch removed this from the 6.0.1 ("Flanders Red Ale") milestone Jul 3, 2019

@brusch brusch closed this in #4550 Jul 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.