Performance when changing the length of a keys value. (It gets really bad.)

Alex Stapleton alexs at advfn.com
Wed Jul 13 09:39:38 PDT 2005


On 13 Jul 2005, at 17:27, Alex Stapleton wrote:

> I am running under Debian 3.0 with Linux 2.4.23, Quad 2.4 GHz P4  
> Xeon. 2GB RAM. My memcached is running with these options
>
> /usr/bin/memcached -m 128 -p 11211 -u root -c 1024
>
> Performance is generally rather good. I can push 6000-7000 requests/ 
> s doing over 100MB/s of data in throughput. However! In my test  
> code, if I change the data block size from 8192 bytes, to 1024  
> bytes, without restarting the server, Performance suddenly becomes  
> hideously slow. So slow in fact, the tests which where taking only  
> 2-3 seconds to complete, now take over 10 times longer, reducing my  
> requests a second from several thousand, to below 10!
>
> Does anyone have any suggestions as to why this might be? I am  
> writing approximately 80 MB of data to the server in my tests,  
> using the same keys between tests, so they should just get  
> overwritten, right? I expect it is due to memcached suddenly  
> deciding to re-malloc or free memory when I reduce the data size.
>
> Here is my test script. It is written in Python using the danga  
> memcached module. I hope nothing mangles the formatting.
>
> import time
> import memcache
>
> mc = memcache.Client(['127.0.0.1:11211'], debug=0)
>
> iters = 100
> data_len = 4098
>
> data = "B" * data_len
>
> s = time.time()
>
> for i in xrange(1,iters):
>         mc.set(i, data)
>
> e = time.time()
> took = (e-s)
>
> print "Took %s seconds" % (took)
> print "Wrote at least %s MB of data" % ((data_len*iters)/1024/1024)
> print "%s t/s" % (iters/took)
> print "%s s/t" % (took/iters)
> print "%s MB/s" % ((data_len*iters/took)*2/1024/1024)
>

I have just tried this test using replace() instead of set() under  
the impression that it might do something vaguely more efficient. It  
doesn't. It is still slow.


More information about the memcached mailing list