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

APCu cache fragmentation can cause PHP processes to lock up #138

Open
danielbachhuber opened this issue Jul 6, 2017 · 5 comments
Open
Labels

Comments

@danielbachhuber
Copy link
Member

This issue is long overdue but...

Pantheon isn’t running WP LCache in production because we’ve discovered a problem with APCu’s memory allocation algorithm. If your configuration gets to a point where APCu is >95% full and heavily sharded, then APCu can cause your PHP processes to lock up and your web node to stop serving requests. This is a problem specific to APCu, and not LCache, so you could see it manifest with any APCu-based object cache drop-in.

[...]

At a high level, the memory allocation problem manifests itself when the APCu is heavily fragmented and close to full (> 99% utilization). It reproduces consistently if you can mock the environment correctly. The symptom of the issue is that PHP processes begin to lock up when APCu can no longer write new cache entries. One process locking causes all of the other processes to lock because APCu becomes inaccessible.

Here’s a script you can use to reproduce the issue in a test environment: https://gist.github.com/danielbachhuber/e0b39ae91a6a2b7ab79232df145f8b5a

From https://wordpress.org/support/topic/heavy-iops-and-database-use/

@wkhayrattee
Copy link

wkhayrattee commented Jul 7, 2017

The idea behind this cache is very nice and APCu is faster. Would be great if this issue can be resolved.
Thanks @danielbachhuber for opening a ticket and your efforts to get this moving.

cheers

@danielbachhuber
Copy link
Member Author

Would be great if this issue can be resolved.

Just to clarify, the issue is in APCu, not LCache. It appears to be an architectural flaw with APCu that would be very challenging to remedy. As such, Pantheon has explored alternatives, but none of the exploration has born fruit yet.

@jchristi
Copy link

jchristi commented Jun 27, 2018

Per David Strauss's comments here: lcache/lcache#87 (comment) . The TL;DR is basically that the above mentioned "explored alternatives" performed about the same as a local memcache over unix socket, however there is no memcache L1 interface written yet for LCache and it doesn't sound like anyone is working on writing that.

@unknys
Copy link

unknys commented Oct 22, 2019

Wt3 Total Cache is the only plugin as i know off which APCu is working PERFECT on! And what an amazing and insane feature it is! My site speed level alone without any other plugin with APCu went up 67% Ofcourse it ALL depends on how much Memory Cache you make available to it. It makes the respond time with databases quicker, handling http specially with http2 on a whole new level!

@melbit-dannyw
Copy link

Has this been tested with a newer version of APCu, as I can see that in release 5.1.15 (2018-12-07), there is a note that they have made changes to attempt to reduce shared memory fragmentation?

Pecl Page: https://pecl.php.net/package/APCu
ChangeLog: https://pecl.php.net/package-changelog.php?package=APCu

5.1.15

  • Restore apc.serializer=php as the default, as the "default" serializer still/again has issues.
  • Fix possible issues in persistence of arrays with the "default" serializer.
  • Attempt to reduce shared memory fragementation.

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

No branches or pull requests

5 participants