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

Alex Stapleton alexs at advfn.com
Wed Jul 13 09:58:55 PDT 2005


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

>
> 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)
>>
>>
>
> Hmmm, I thought -k fixed this, but it seems to just make the issue  
> less obvious. Now if I switch between extremes (31Kb blocks (32KB  
> ones are VERY slow) to 1 byte blocks) the performance become  
> increadibly bad again! With -k enabled I don't see why it should be  
> doing this.
>


Writing at least 15 MB of data in 1000, 16 KB blocks
Took 0.169834136963 seconds
5888.09775162 t/s
0.000169834136963 s/t
184.003054738 MB/s

vs

Writing at least 0 MB of data in 100, 2 KB blocks
Took 20.7834701538 seconds
4.81151603943 t/s
0.207834701538 s/t
0.018794984529 MB/s

t/s is requests a second
s/t is seconds a request


More information about the memcached mailing list