tutorial

Monitoring Memcached with Vigilmon

Memcached is the silent workhorse behind high-traffic web applications. When it goes down, database load spikes and pages slow to a crawl. Here's how to monitor Memcached TCP availability, stats health, phpMemcachedAdmin, SSL, and application cache health with Vigilmon.

Memcached is the world's most widely deployed distributed in-memory key-value cache — powering Facebook, Wikipedia, YouTube, and thousands of high-traffic web applications. Its job is to absorb database read load and accelerate page rendering by serving frequently accessed data from RAM. When Memcached fails silently — the process crashes, the port closes, or memory fills without eviction — applications fall back to the database, causing immediate latency spikes and often cascading failures. Vigilmon lets you catch Memcached failures at the TCP and application layer before users notice the slowdown.

What You'll Set Up

  • TCP port monitor for Memcached on port 11211
  • Stats endpoint health check via TCP keyword verification
  • HTTP monitor for phpMemcachedAdmin (if deployed)
  • SSL certificate alerts for TLS-wrapped Memcached deployments
  • Heartbeat monitor for application-layer cache health checks

Prerequisites

  • Memcached running and bound to port 11211
  • phpMemcachedAdmin deployed (optional, for the web UI step)
  • A free Vigilmon account

Step 1: Monitor Memcached TCP Port Availability

The most fundamental Memcached check is whether port 11211 is open and accepting connections. A TCP failure here means the Memcached process has crashed or the system has run out of file descriptors.

  1. Log in to vigilmon.online and click Add Monitor.
  2. Set Type to TCP Port.
  3. Host: YOUR_HOST (use 127.0.0.1 or your server's IP; Memcached should not be exposed to the public internet).
  4. Port: 11211.
  5. Set Check interval to 1 minute.
  6. Click Save.

If Memcached is bound only to 127.0.0.1 (the recommended production configuration), run Vigilmon's monitoring agent on the same host, or use a lightweight TCP relay/proxy that the external Vigilmon probe can reach. Never expose Memcached port 11211 to the public internet — it has no authentication.


Step 2: Verify the Memcached Stats Endpoint

A TCP connection succeeding only confirms the port is open. Checking the stats command response confirms Memcached is actually processing commands, not just holding the socket open in a broken state.

  1. Add MonitorTCP Port (advanced keyword check).
  2. Host: YOUR_HOST, Port: 11211.
  3. Under Advanced, enable Send string on connect: stats\r\n
  4. Set Expected response contains: STAT pid
  5. Set Check interval to 2 minutes.
  6. Click Save.

The STAT pid line is always the first line of a healthy stats response, confirming that Memcached is running, accepting commands, and returning valid output. A missing or malformed response indicates a severely degraded process.


Step 3: Monitor phpMemcachedAdmin (If Deployed)

phpMemcachedAdmin is a popular open-source web interface for monitoring and managing Memcached servers. If you have it deployed, its availability is a proxy for both the web server and Memcached connectivity.

  1. Add MonitorHTTP / HTTPS.
  2. URL: http://YOUR_HOST/phpMemcachedAdmin/index.php (or your configured path).
  3. Set Expected HTTP status to 200.
  4. Under Advanced, set Expected body contains to Memcached (the page title).
  5. Set Check interval to 5 minutes.
  6. Click Save.

phpMemcachedAdmin is an admin tool, not a production-critical service, so a longer check interval is appropriate. If it returns an error, it may indicate that phpMemcachedAdmin itself cannot connect to Memcached — a useful secondary signal.


Step 4: SSL Certificate Alerts for TLS-Wrapped Deployments

Modern Memcached (1.6+) supports native TLS, and many deployments wrap Memcached behind stunnel or an nginx TCP proxy to encrypt cache traffic. Monitor the certificate on the TLS terminator to catch renewal failures.

For stunnel or nginx TCP proxy:

  1. Add MonitorHTTP / HTTPS (using the HTTPS endpoint of any service that communicates through your TLS-wrapped Memcached).
  2. Enable Monitor SSL certificate.
  3. Set Alert when certificate expires in less than 14 days.
  4. Click Save.

If you use native Memcached TLS (port 11211 with TLS), add a TCP monitor with keyword check as in Step 2, and separately monitor the certificate expiry of the cert file via your server's certificate renewal heartbeat (see Step 5).


Step 5: Heartbeat Monitor for Application Cache Health

The most business-critical Memcached check is whether your application is successfully using the cache. High miss rates or connection failures at the application layer may not be visible at the TCP level. Many applications expose a health endpoint that includes cache connectivity status.

Set up a Vigilmon heartbeat that your application health check script pings:

  1. In Vigilmon, Add MonitorHeartbeat.
  2. Name it App Cache Health.
  3. Set Expected interval to 5 minutes.
  4. Copy the generated heartbeat ping URL.

If your application exposes a health endpoint with cache status (e.g. /health returns {"cache":"ok"}), create a monitoring script:

#!/bin/bash
# Check application-layer Memcached health
RESPONSE=$(curl -sf https://YOUR_APP/health)
if echo "$RESPONSE" | grep -q '"cache":"ok"'; then
  curl -fsS YOUR_HEARTBEAT_URL > /dev/null 2>&1
fi

Schedule it via cron:

*/5 * * * * /usr/local/bin/cache-healthcheck.sh

Alternatively, use Vigilmon's HTTP keyword monitor directly on your application's health endpoint:

  1. Add MonitorHTTP / HTTPS.
  2. URL: https://YOUR_APP/health
  3. Under Advanced, set Expected body contains to "cache":"ok".
  4. Set Check interval to 2 minutes.
  5. Click Save.

This catches the scenario where Memcached appears up at the TCP level but the application can no longer establish connections (e.g., max connection limit hit, SASL auth failure).


Step 6: Alert Channels and Grouping

  1. Go to Alert Channels in Vigilmon and configure your preferred channel (email, Slack, or webhook).
  2. Group Memcached monitors under a Memcached service group.
  3. Set the TCP port monitor (Step 1) with the highest alert priority — a TCP failure means total cache unavailability, which immediately impacts all application database load.
  4. Set Consecutive failures before alert to 2 — transient connection spikes can briefly close and reopen connections without a real outage.

Summary

| Monitor | Target | What It Catches | |---|---|---| | TCP port | Port 11211 | Process crash, file descriptor exhaustion | | Stats keyword | STAT pid response | Command processing failure | | phpMemcachedAdmin | HTTP UI | Admin UI crash, Memcached connectivity | | SSL certificate | TLS proxy cert | Certificate renewal failure | | App cache health | /health endpoint | Connection limit, auth failure, app-layer miss |

Memcached failures are silent and fast — within seconds of the process going down, database queries that the cache was absorbing begin hammering your storage layer directly. Vigilmon's external TCP and heartbeat checks give you the earliest possible warning, before the performance impact becomes visible to users.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →