Reputation: 666
I have site which is using Memcached hard. Now it takes 7Gb of memory, every page makes a couple of gets and sets storing full pages and so on. Also I have a very dynamic sidebar which is also stored in Memcached updated and requested very often. I've noticed that this particular key takes too long to fetch. For example fetching full page takes 1-2 ms but fetching sidebar takes about 50ms! I do this request on every page and I don't like it at all, when full request takes 200-300ms 50ms for memcached get is not acceptable.
Does it have anything to do with frequent updates for this key? If yes is there any way to fix it? Maybe I should use Redis or MySQL? Or maybe switching to PHP Memcached extension instead of Memcache will help? If not, what other reason can cause this behaviour?
UPD: memcache set on this key takes CRAZY 250ms!
Upvotes: 1
Views: 782
Reputation: 666
I found the problem and it was my fault. But since I see 2 stars on the question I will answer to let that people know what actually happened. So because of the bug in my code the value I stored was very large (array with 3500 items instead of 20 I actually needed) and that was the reason of huge speed decrease. Before I found this I checked memcached thinking of switching to it. Here are time measures for this problematic key (in ms):
memcache get
42.184829711914
memcache set
153.13792228699
memcached get
14.186859130859
memcached set
0.093936920166016
Memcached shows much better result for get (but still not 0-1ms) and great result for write. I was ready to use it but then checked another key which is simple and works fast with memcache:
memcache get
0.17499923706055
memcache set
0.10800361633301
memcached get
6.850004196167
memcached set
0.012874603271484
So on my server memcached shows great speed on writes but not so good on reads. Good thing is that is doesn't decrease it depending on the value size. Maybe some day this information will become useful for me :)
Upvotes: 1