Most Drupal website administrators are interested in quickly monitoring memcache's statistics, and the nc
command is a useful command for interacting with memcache servers. The following details the following functions that can used for memcache servers:
With the Cloud Platform infrastructure being a kubernetes framework, and Acquia’s non-Kubernetes version, referred to as Cloud Classic infrastructure, there is a difference of for each infrastructure. This article provides commands for both of these, for each memcache server interaction functionality.
Note
In order to run the commands below you need to first connect through SSH into the web server.
If you are running on the Cloud Platform infrastructure, use the acquia-memcache
command, instead of the nc
command.
For Acquia Cloud Platform, use the command:
acquia-memcache stats
As a preliminary step, you'll need a list of the memcache servers that Drupal is using. As an Acquia Cloud customer, you can find your memcache servers by navigating to the Application > Environment > Infrastructure (Classic) page in the Acquia Cloud UI. Find the "web" server(s) that have "Memcache" and note their full DNS name (e.g. "web-123.prod.hosting.acquia.com").
If you have a Drupal 7 application, you can use the following Drush command to look up the memcache_servers
variable:
drush vget memcache_servers
The output should look something like this:
memcache_servers: Array (
[server-1234.prod.hosting.acquia.com:11211] => default
[server-5678.prod.hosting.acquia.com:11211] => default
)
This array is automatically populated on Acquia Cloud servers using memcache.
The format of the servers' array is hostname:port => bin
. In the sample output, the default memcache bin is split across two memcache hosts — server-1234.prod.hosting.acquia.com
and server-5678.prod.hosting.acquia.com
, using port 11211 on each host.
The Memcached protocol provides a stats
command that can provide some insight into a few dozen server variables. Many of these server variables count the number of times a particular event occurred since the service was launched.
In this example, we echo two commands together: stats
, followed by quit
(separated by a newline). The -q1
option tells the nc
command to not disconnect immediately. Without this option, nc
might close the connection before it delivers the output.
Note
You can only use nc
to connect to a server running memcached from another server in the same cluster. Users cannot connect from their local computers — they must instead SSH into one of their web servers to run these commands.
/bin/echo -e 'stats\nquit' | nc -q1 [memcache hostname] [port number]
Here's an example using server information from the previous example:
/bin/echo -e 'stats\nquit' | nc -q1 $(hostname -s) 11211
The output of the preceding command should look similar to the following:
STAT pid 1216
STAT uptime 2472376
STAT time 1373572082
STAT version 1.4.5
STAT pointer_size 64
STAT rusage_user 66.790000
STAT rusage_system 110.900000
STAT curr_connections 3
STAT total_connections 297279
STAT connection_structures 10
STAT cmd_get 2115470
STAT cmd_set 92126
STAT cmd_flush 0
STAT get_hits 1918776
STAT get_misses 196694
STAT delete_misses 806
STAT delete_hits 1566
STAT incr_misses 0
STAT incr_hits 19
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 346432348
STAT bytes_written 3932785939
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 1
STAT conn_yields 0
STAT bytes 46704290
STAT curr_items 21955
STAT total_items 92127
STAT evictions 13531
STAT reclaimed 0
END
You can use the watch
command to monitor all of these statistics in real time. For example:
watch -d -n 10 "/bin/echo -e 'stats\nquit' | nc -q1 $(hostname -s) 11211"
Adding the -d
option to the watch command highlights the parts of the output that have changed since the last output. The -n
option sets a delay interval; in this example, it's set to 10 seconds.
To flush memcache on Cloud Platform, SSH into your site and then run this command:
acquia-memcache flush_all
For clearing memcache, you can SSH into the specific server which is running memcache (you can check it on Cloud UI) and then run the below command -
Here's an example:
/bin/echo -e 'flush_all\nquit' | nc -q1 $(hostname -s) 11211
If the command completes normally, the output should simply be OK.
Important
Because the method described in this section involves flushing memcache for all of your websites on a given server, using this flushing method is not recommended. It cannot be localized to a single environment, and is is an abnormal and potentially dangerous course of action that can result in temporary performance issues (or even downtime), especially if the website has a large volume of traffic to its back-end web servers. Other Drupal websites that share the same memcache servers could also be inadvertently affected.
This should be a last resort. If you have concerns, contact Acquia Support.
In most cases, when a particular part of a Drupal page appears "stuck" in cache, you should use the drush cache-clear
command. This command can clear a specific cache that appears to be problematic. In extremely rare circumstances you may need to manually trigger a memcache flush. For Drupal 7 websites, you may need to trigger a registry rebuild function. (For more information, see the Registry Rebuild module on drupal.org.) If these processes fail, you can attempt a manual memcache flush. The memcache protocol flush
command allows you to immediately flag all stored values as invalid.
If this content did not answer your questions, try searching or contacting our support team for further assistance.
Wed Oct 22 2025 08:59:29 GMT+0000 (Coordinated Universal Time)