Debugging a Memcached server

Is your Memcached instance working correctly? Who the hell knows? Well, we will in a minute.

Open your terminal, and use the ancient telnet to connect to your server on the correct port (usually 11211):

$ telnet my.memcache.server.net 11211
Trying my.memcache.server.net...
Connected to my.memcache.server.net.
Escape character is '^]'.

Next we reset existing stats then turn on stats collection:

stats reset
RESET
stats detail on
OK

Now, make a request on your website that will call memcache.

Finally, turn stats collection off, then dump the stats collected. If you have output, your memcached server is successfully caching your keys!

stats detail off
OK
stats detail dump
PREFIX User get 3 hit 2 set 1 del 0
PREFIX Trade get 1 hit 0 set 1 del 0
PREFIX Currency get 1 hit 0 set 0 del 0
PREFIX Orders get 2 hit 0 set 2 del 0
PREFIX Prices get 2 hit 0 set 0 del 0
END

To get out of telnet, you type quit.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s