Not possible to disable memcache, causing slow page loads
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 4
- Forks
- 9
- PR merge metrics
- No merged PRs in 30d
Description
Even if you have cache set to false in .lando.yml (as documented here: https://docs.lando.dev/plugins/acquia/config.html), and do not have a Drupal memcache module installed (disabled for local development environment using config_split Drupal module), memcache related code will run on every page load, causing significant slowness.
While investigating why my site was so slow, I found this issue:
https://github.com/lando/acquia/issues/10
A user there pointed out something extremely problematic for anyone who does not have the Drupal memcache module enabled and configured and does not want to. The issue is caused by the interplay of Lando setting $_ENV['AH_SITE_ENVIRONMENT'] to "LANDO", and the memcache related code in the Acquia created/controlled docroot/sites/default/settings/cloud-memcache-d8.php file.
In cloud-memcache-d8.php, this if statement will ALWAYS be true:
/**
* Use memcache as cache backend.
*
* Autoload memcache classes and service container in case module is not
* installed. Avoids the need to patch core and allows for overriding the
* default backend when installing Drupal.
*
* @see https://www.drupal.org/node/2766509
*/
if (array_key_exists('memcache', $settings) &&
array_key_exists('servers', $settings['memcache']) &&
!empty($settings['memcache']['servers'])
) {
This is because Lando sets the $_ENV['AH_SITE_ENVIRONMENT'] variable, and Acquia creates the $settings['memcache'] array in another Acquia settings file.
Initially I thought I could unset the array in my local.settings.php, but this is not possible, because local.settings.php is ran AFTER cloud-memcache-d8.php.
The only way I have found to avoid this if statement being true is to unset $_ENV['AH_SITE_ENVIRONMENT'] in .lando.yml:
services:
appserver:
overrides:
environment:
AH_SITE_ENVIRONMENT:
This likely has side effects, or else Lando wouldn't bother to set the variable in the first place. However, after adding that and running lando rebuild, my site is significantly faster. Using Xdebug, I can confirm that the if statement in cloud-memcache-d8.php evaluates to false and the memcache code does not run.
Can we find a way to actually disable memcache that plays nicely with Acquia files that we have no control over?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the Acquia cloud-memcache-d8.php behavior with the .lando.yml AH_SITE_ENVIRONMENT override and the documented cache setting. Reproduce the issue with the described Drupal configuration and lando rebuild, then verify that disabling cache prevents the memcache code from running without unintended environment side effects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- drupal, memcached
- Domain
- backend, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100