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

Provide default services.yml, including APCu config #40

Closed
danepowell opened this issue May 9, 2016 · 7 comments
Closed

Provide default services.yml, including APCu config #40

danepowell opened this issue May 9, 2016 · 7 comments

Comments

@danepowell
Copy link
Contributor

On one of our ACE sites, we are seeing failing page loads with this error:
"Warning: apcu_store(): Unable to allocate memory for pool. in Drupal\Core\Cache\ApcuBackend->set() (line 177 of core/lib/Drupal/Core/Cache/ApcuBackend.php)."

According to support, this is due to Drupal 8 using APCu for some types of caching, which has a hardcoded memory limit that is too low.

The "strongly recommended" fix is to add the following to services.yml to tell Drupal to use the database instead of APCu for these types of caching:

services:
  cache.backend.chainedfast:
    class: Drupal\Core\Cache\ChainedFastBackendFactory
    arguments: ['@settings', 'cache.backend.database', 'cache.backend.database']
    calls:
      - [setContainer, ['@service_container']]

The long-term fix is to use Memcache, but memcache is not currently stable or recommended for D8.

Seems like Bolt should provide services.yml with this config by default.

We're testing this fix right now, and if it works will report back and try to open a PR.

grasmash added a commit that referenced this issue May 20, 2016
Resolves #40: Disable APCu caching to prevent memory exhaustion
@csedev
Copy link

csedev commented Jul 18, 2016

Receiving the following error message after applying this change.

PHP Fatal error: Consistent cache backend and fast cache backend cannot use the same service.

What am I missing?

@geerlingguy
Copy link
Contributor

I'm getting the same error now as @csedev, at least in local testing...

@csedev
Copy link

csedev commented Jul 21, 2016

Acquia platform assigns a hard 8 MB limit to this cache backend, which is adequate for small cache pools, but was not meant to be used as a default cache backend. Unfortunately, Drupal 8 attempts to use APCu as a cache backend by default if possible.

In the meantime, I was able to avoid this issue altogether by telling Drupal not to use the APC user cache backend by default, instead relying on the MySQL database as a cache backend.

You can do this by adding the following line of code to your site's settings.php file:

$settings['cache']['default'] = 'cache.backend.database';

@geerlingguy @danepowell

@geerlingguy
Copy link
Contributor

@grasmash - It seems the services.yml approach is preferred, at least according to Acquia support, but it wasn't working for me locally (see above referenced error)—should we recommend a settings.php change like @csedev used above, or work out the issue with services.yml?

@grasmash
Copy link
Contributor

I suggest that we do what works for now and raise the issue with Acquia support regarding documentation of best practice.

@geerlingguy
Copy link
Contributor

geerlingguy commented Jul 21, 2016

@grasmash - Thanks! Testing the settings.php fix now.

[Edit: It works!]

@bradjones1
Copy link

For anyone finding this in the future, the correct way to do this is documented at:

https://github.com/acquia/blt/blob/f0d02496371462c7fc0e64909789b10ded9c0cd5/settings/apcu_fix.yml

Also see https://www.drupal.org/node/2662844

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants