Cloud Platform

PECL Memcached extension

The PECL Memcached extension provides a PHP-based API that can communicate with the Memcached service. The classes and functions in the extension accomplish the following tasks:

  • Consume the list of configuration and connection details of the infrastructure running Memcached from the Drupal Cache API configuration.
  • Receive directives from Drupal’s Cache API​, such as cache_set() and cache_get and translate them into commands that can be interpreted by the Memcached service. For more information about Drupal integration, see Drupal and the Memcache module.

Infrastructure and scaling

For environments running on Cloud Next technologies, Acquia’s Memcached architecture runs in a high-availability configuration with at least two nodes behind mcrouter. The amount of memory available to Memcached can be configured in the Cloud Platform user interface on the Advanced tab of the Environment Settings page. All Memcached nodes operate with the assigned memory limit. For more information, see memory limit.

For environments running on the Cloud Classic infrastructure, Acquia’s Memcached architecture enables Memcached to either share memory with other processes across multiple infrastructure or be consolidated onto dedicated Memcached infrastructure.

Memcached infrastructure in a hash ring is unaware of other nodes within the ring. Each infrastructure knows which data in its local array is least recently used and will purge that data accordingly to make room for newer requests.


At the beginning of a request, Drupal uses the Memcache API and Integration module to pass all connection information to the PECL Memcached PHP extension. This includes an array of available infrastructure. For example:

web-1234, web-1235, web-1236

Each of these host names are hashed and converted to an integer, decreasing the likelihood that the infrastructure will appear in alphanumeric, sequential order. By doing this, the process increases the likelihood of webs being distributed evenly in the hash ring. The array of infrastructure is passed to the Memcached service, which maps each value to a hash ring. Memcache does this several times per infrastructure, using different hashing parameters, with the goal of creating an even distribution of infrastructure endpoints throughout the loop. After all hostname points have been mapped, objects are encoded using the following:

$full_key = urlencode($prefix . $bin . '-' . $key);

This creates a key in the following format:

The objects are hashed using the crc32 hashing algorithm and mapped in a similar fashion.


Infrastructure and objects are mapped to the hash ring with an absolute value, allowing the Memcached service to quickly determine where they exist. If any infrastructure in the loop or array are removed, the website will not lose all of its cached data and the PECL Memcached extension will evenly distribute the load amongst the remaining parts of the infrastructure.