ngrep and memcache

May 14, 2008

Tags: , , ,

You can use the Linux command ngrep to "watch" what is going into and coming out of memcache. ngrep is an amazingly useful tool for troubleshooting a wide array of network issues; I previously have used it extensively for troubleshooting SIP errors. In this case, I’m using it to be sure memache sessions in PHP are actually working.

codelemur ~ # ngrep -d lo port 11211
interface: lo (127.0.0.0/255.0.0.0)
filter: (ip) and ( port 11211 )
####
T 127.0.0.1:60912 -> 127.0.0.1:11211 [AP]
get a804f5517468d4696c60da7eaf8a7179..
##
T 127.0.0.1:11211 -> 127.0.0.1:60912 [AP]
VALUE a804f5517468d4696c60da7eaf8a7179 0 16..test|s:4:"test";..END..
##
T 127.0.0.1:60912 -> 127.0.0.1:11211 [AP]
set a804f5517468d4696c60da7eaf8a7179 0 1440 16..test|s:4:"test";..
#
T 127.0.0.1:11211 -> 127.0.0.1:60912 [AP]
STORED..

It doesn’t help too much if you have multiple memcache servers (which is kinda the point of memcache), and since it’s raw data you can’t inspect the packets if they’re compressed, but in a testing environment, it’s a great way to be sure all things are kosher.

Leave a Reply