Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Persistent connections are only supported when using the Memcache extension.
We should add support for the same feature using the Memcached extension.
Comment | File | Size | Author |
---|---|---|---|
#5 | memcached-persistent-1977452.patch | 3.81 KB | Jeremy |
#1 | memcache-persistent-connections-1977452-1.patch | 2.21 KB | markpavlitski |
Comments
Comment #1
markpavlitski CreditAttribution: markpavlitski commentedComment #2
Phizes CreditAttribution: Phizes commentedmarkpavlitski: I would like to test this, though I am not sure how to check that it is indeed functioning correctly, could you possibly provide an idea or methodology as to how to go about it? (I'm probably missing something.)
Thanks.
Comment #3
markpavlitski CreditAttribution: markpavlitski commented@Phizes I think you should be able to monitor the number of open connections to your Memcached instance by looking at the curr_connections and total_connections stats.
total_connections should increase for every page load when using a non-persistent connection (as a new connection is opened every time), but it should only increase periodically when using persistent connections (when the connection times-out or is dropped/reset).
If you want to dig into it a bit further, $memcache->getServerList() should return a list of any servers that have persistent connections open (i.e. they were opened on a previous page load) and $memcache->isPersistent() will tell you if an open connection is persistent or not.
Comment #4
Phizes CreditAttribution: Phizes commentedPlease keep in mind that I was using Unix sockets with this patch, I'm not sure what effect this has. I was using the latest dev version, both when running with, and without the patch.
I ran with this patch for a while, then without it, and then with it again. Both the times I was running with this patch I saw somewhat severe performance degradation, as in 50% time or more spent in PHP than without the patch. I kept an eye on this using New Relic, I didn't do any screen grabs, which is unfortunate, and I'm only using the lite version, so data retention is only 24 hours.
To me it seems that it is not reusing the persistent connections it creates, memstat reported that there were ~20+ persistent connections at any given time, but the connection count statistic kept growing as normal. Without the patch there were no persistent connections mentioned.
I've been delaying reporting back on my results as I wanted to look into it further, and maybe find a solution, but I lack the time currently.
Comment #5
Jeremy CreditAttribution: Jeremy commentedHere's a patch that works a bit better. However, there's still the occasionally connection leak visible on the statistics page -- this is probably from memcache_requirements calling memcache_instance without a bin. I suspect the best solution is to ignore the memcache_persistent option when doing requirements testing.
Comment #7
Jeremy CreditAttribution: Jeremy at Tag1 Consulting commentedDid a little cleanup to my earlier patch and committed. And, enabled persistent connections by default.