More memcached

While playing with memcached I wanted to find a way to monitor what was getting set.  You see, we are trying to pre-warm our cache with lots of colours. (roughly 16.5 million of them :) )

Anyway, I remembered I’d had a play a (long) while ago with expect and decided it would be just the thing…

So here we are – a status report from memcached every 5 minutes.

#!/bin/bash
# script to monitor memcached

expect << EOF
set timeout 1
spawn telnet localhost 11211
while 1 {
send "stats\n";
expect #
send "stats slabs\n";
expect #
puts "sleeping for 5 mins"
sleep 300;
}

# ends

Our pre_warming script has been running for almost an hour and has warmed the cache with 319116 items – so about 52 hours to go….

In terms of memory usage, I am running memcached with a Gig of Ram, and after the hour we are only using 4.7 meg of that :) . So my estimate is that we would need approximately 250MB.

Target = 16,581,375 items (colours)
1 hour = 319,116 items
1 hour = 5,005,741 bytes written
so 16,581,375/319,116 = 51.96 Hours
so 5,005,741*51.96 = 260,098,302 bytes = 248.05 MB

And now I’ve done these calculations, something makes me want to revist my memcache monitor script so that I pass it a target and then get a “time left” estimate :)

One Response to “More memcached”

  1. Rich F says:

    As if by conincidence this was blogged a couple of days ago…

    http://www.mysqlperformanceblog.com/2008/11/26/a-quick-way-to-get-memcached-status/

    I really can’t believe how much fast CP (dev) is than CP (live) … can’t wait to get it out there :) .

Leave a Reply