Cache Full

Jamie Burns fantasticjamieburns at
Wed Aug 2 00:35:05 UTC 2006


I am doing some tests to see if memcache will help my application.

For test purposes, I started memcache with 16MB of memory with this command:

    /usr/bin/memcached -m 16 -p 11211 -u root

I wrote a simple benchmark script in PHP that writes a 2k string to memcache 40,000 times, with an incremental key (10,000 - 39,999) and then reads at random 80,000 keys back.

Now, firstly I know that 40,000 2k strings will more than fill the cache! The idea was to stress it a little :o)

So the benchmark ran quite well, in both reading and writing (nowhere near as fast as a local tmpfs mounted ramdisk, but hey, it supports distribution across machines).

After I have done this benchmark, trying to write another sized key (not 2k) takes an age and slows my application down to a halt (down from 65 pages per second, to 8 pages per second).

So I have been reading about slab allocators and see that is the problem - but how can this be fixed?! Why does it take so long to find out it cannot store the key?

I cannot have my application grind to a halt because a cache is full - it would be far better without it.

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the memcached mailing list