Nikhil
Nikhil

Reputation: 473

PHP memcache returns false with increase in number of keys

We are working with PHP and are using memcached v1.4.6 for caching. We are using memcache extension memcache-2.2.6 from PECL. We are using persistent connection to connect to memcached.

Recently we made some changes that has doubled the number of keys stored in memcached. These keys are at max 75 to 80 characters long. The values stored are integers.

Whenever we try working with the new code, the system works fine for the first few seconds (usually less than 10 seconds). After the first few seconds, memcache starts returning "false" for every request (get, set, increment)

If at this stage we revert back to the old code, things start working fine again.

The request rate on our memcached server is about 270 requests per second (with the old code). This is expected to grow to over 1000 requests per second with the new code.

When memcache starts returning "false", around 15% of the allocated memory is free.

What could be causing this behaviour?

Upvotes: 2

Views: 2881

Answers (1)

capi
capi

Reputation: 1453

Looks like it could be a compression or serialization problem. I would suggest doing more debugging to see the exact server response. First, try doing a telnet and setting and getting the keys manually :

telnet a.b.c.d 11211
SET key_name 0 300 3
123
STORED
GET a
VALUE a 0 3
123
END

See :

http://code.google.com/p/memcached/wiki/NewCommands http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt

for protocol commands.

If all looks well you could try a monitor on the server to see the commands being executed :

telnet a.b.c.d 11211
STATS detail on
//wait a while
STATS detail off
STATS detail dump
//list of commands will be dumped

You can tweak the library a bit by its runtime configuration in php.ini :

http://www.php.net/manual/en/memcache.ini.php

And maybe you could check out PHP's Memcached (notice the D) library as an alternative.

Also, a good monitoring tool :

http://code.google.com/p/phpmemcacheadmin/

Upvotes: 2

Related Questions