随着键数量的增加,PHP memcache返回false [英] PHP memcache returns false with increase in number of keys

查看:47
本文介绍了随着键数量的增加,PHP memcache返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用PHP,并且正在使用memcached v1.4.6进行缓存.我们正在使用PECL的memcache扩展memcache-2.2.6.我们正在使用持久连接来连接到memcached.

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.

最近,我们进行了一些更改,使存储在memcached中的键的数量增加了一倍.这些键的最大长度为75至80个字符.存储的值是整数.

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.

每当我们尝试使用新代码时,系统在最初的几秒钟(通常少于10秒)内都可以正常工作.在最初的几秒钟之后,内存缓存针对每个请求(获取,设置,递增)开始返回"false"

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.

我们的内存缓存服务器上的请求速率约为每秒270个请求(使用旧代码).使用新代码,预计每秒可以增加超过1000个请求.

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.

当memcache开始返回"false"时,大约15%的已分配内存可用.

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

什么可能导致这种行为?

What could be causing this behaviour?

推荐答案

看起来像是压缩或序列化问题.我建议进行更多调试,以查看确切的服务器响应.首先,尝试进行telnet并手动设置和获取密钥:

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

请参阅:

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

用于协议命令.

如果一切正常,您可以尝试在服务器上的监视器上查看正在执行的命令:

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

您可以通过php.ini中的运行时配置对库进行一些调整:

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

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

也许您可以查看PHP的 Memcached (注意D )库.

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/

这篇关于随着键数量的增加,PHP memcache返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆