Monday December 01, 2008
Displaying the 10 most popular keys in your memcached instance?
If you run your memcached-server on Solaris you can easily display the 10 most popular keys in you memcached server by using dtrace. The following little script will display the 10 most popular keys every 10th second.
#! /usr/bin/ksh
pid=`pgrep -x memcached`
if [ -z "${pid}" ]
then
echo memcached not running
exit 1
fi
file /proc/${pid}/path/a.out | grep "ELF 64" > /dev/zero 2>&1
if [ $? -ne 0 ]
then
mode="-32"
else
mode="-64"
fi
/usr/sbin/dtrace ${mode} -n '
#pragma D option quiet
memcached'${pid}':::assoc-find
{
@assK[copyinstr(arg0)] = count();
}
tick-10s
{
printf("Top 10 keys\n");
trunc(@assK, 10);
printa(@assK);
trunc(@assK, 0);
}
END {
trunc(@assK, 10);
printa(@assK);
trunc(@assK, 0);
}
'
You may find the probe name assoc-find strange, but that is a function that is called for all commands when the memcached server tries to locate an item in the cache. By using that probe, we can count all get/add/set/replace/delete with one single probe :-)
Posted at 11:13PM Dec 01, 2008 by trond in Memcached | Comments[2]
| « December 2008 » | ||||||
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
2 | 3 | 5 | 6 | |||
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 18 | 19 | 20 | |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | |||
| Today | ||||||