Acquia Copilot is a conversational AI connected into our product documentation and knowledge base. Ask Copilot about product features, technical details, troubleshooting and how to get started with Acquia products.
Excessive database load may overwhelm the Drupal’s semaphore table, which can cause deadlocks. Encountering deadlocks during database write operations (including INSERT, UPDATE, and DELETE operations) can indicate that Drupal’s lock API is in conflict with InnoDB’s row-level locking mechanism on Drupal’s semaphore table.
Acquia recommends you keep the semaphore locking mechanism in your InnoDB database, due to your InnoDB database being a persistent storage location. Due to semaphore locks being intended for persistent storage, Memcached (as non-persistent storage) isn’t an ideal location for this use case.
Important
If you want to use Memcached to store your semaphore locking mechanism, and are both willing to assume the risk and have tested the effects on your application, the Memcache API and Integration module provides the features and instructions necessary to store Drupal’s semaphore table in Memcached.
Stampede protection
You can also use Memcached to provide stampede protection. In certain situations, using Memcached can help reduce the risk of performance degradation when several requests simultaneously try to write to the cache.
Stampede protection uses Drupal’s locking layer to allow only one process at a time to try to send an item to Memcached. However, MySQL’s InnoDB storage engine isn’t well-suited to managing locks in the semaphore table when experiencing high loads. Due to this behavior, it’s important to also move lock management out of the database and into memory if you enable stampede protection.
Acquia strongly recommends that you review the Memcache module’s README.txt file for complete documentation about its configuration:
Enabling stampede protection without moving locks into Memcached can cause a severe performance degradation if Memcached locks, and then waits to retry. You can use Memcache for lock management without enabling stampede protection.
For instructions about how to enable stampede protection and Memcache lock management in your Drupal application, select the tab that indicates your installed version of Drupal:
Complete the following steps:
Download and add the memcache.yml file to your website’s docroot/sites/[site_folder] directory. For a single site configuration, the directory is docroot/sites/default.
Add the following lines at the end of the relevant file to enable stampede protection, remembering to replace [site_folder] with your site directory name:
For Cloud Platform : docroot/sites/[site_folder]/settings.php file
For Site Factory : factory-hooks/post-settings-php/acsfd8.memcache.settings.php file
Disabling stampede protection and lock management in Memcache
To disable stampede protection and lock management in Memcache:
Remove any memcache.yml file from the website's directories, docroot/sites/[site_folder].
To disable stampede protection, remove the following lines from your settings.php file. Note that the code lines might not appear next to each other in your file.
Enabling stampede protection and moving locks into memory
Excessive database load may overwhelm the Drupal’s semaphore table, which can cause deadlocks. Encountering deadlocks during database write operations (including INSERT, UPDATE, and DELETE operations) can indicate that Drupal’s lock API is in conflict with InnoDB’s row-level locking mechanism on Drupal’s semaphore table.
Acquia recommends you keep the semaphore locking mechanism in your InnoDB database, due to your InnoDB database being a persistent storage location. Due to semaphore locks being intended for persistent storage, Memcached (as non-persistent storage) isn’t an ideal location for this use case.
Important
If you want to use Memcached to store your semaphore locking mechanism, and are both willing to assume the risk and have tested the effects on your application, the Memcache API and Integration module provides the features and instructions necessary to store Drupal’s semaphore table in Memcached.
Stampede protection
You can also use Memcached to provide stampede protection. In certain situations, using Memcached can help reduce the risk of performance degradation when several requests simultaneously try to write to the cache.
Stampede protection uses Drupal’s locking layer to allow only one process at a time to try to send an item to Memcached. However, MySQL’s InnoDB storage engine isn’t well-suited to managing locks in the semaphore table when experiencing high loads. Due to this behavior, it’s important to also move lock management out of the database and into memory if you enable stampede protection.
Acquia strongly recommends that you review the Memcache module’s README.txt file for complete documentation about its configuration:
Enabling stampede protection without moving locks into Memcached can cause a severe performance degradation if Memcached locks, and then waits to retry. You can use Memcache for lock management without enabling stampede protection.
For instructions about how to enable stampede protection and Memcache lock management in your Drupal application, select the tab that indicates your installed version of Drupal:
Complete the following steps:
Download and add the memcache.yml file to your website’s docroot/sites/[site_folder] directory. For a single site configuration, the directory is docroot/sites/default.
Add the following lines at the end of the relevant file to enable stampede protection, remembering to replace [site_folder] with your site directory name:
For Cloud Platform : docroot/sites/[site_folder]/settings.php file
For Site Factory : factory-hooks/post-settings-php/acsfd8.memcache.settings.php file
Disabling stampede protection and lock management in Memcache
To disable stampede protection and lock management in Memcache:
Remove any memcache.yml file from the website's directories, docroot/sites/[site_folder].
To disable stampede protection, remove the following lines from your settings.php file. Note that the code lines might not appear next to each other in your file.