In our current use of memcached, we are running into problems in a high volume server because so much time is used setting up and tearing down connections to our memcache server. Would using persistent connections to memcached help alleviate this problem?
在我们目前使用的memcached中,我们在高容量服务器中遇到问题,因为使用了很多时间设置和拆除与memcache服务器的连接。使用持久连接到memcached有助于缓解这个问题吗?
Also, what is the preferred way to connect and use persistent memcahced connections? I was thinking of setting a "pool_size" variable then randomly choosing from 1-$POOL_SIZE
and using that connection
此外,连接和使用持久memcahced连接的首选方法是什么?我正在考虑设置一个“pool_size”变量,然后从1- $ POOL_SIZE中随机选择并使用该连接
$mem = new Memcached(rand(1, $pool_size));
Either I am looking in the wrong place or there is not a lot of information on this out there.
要么我在错误的地方寻找,要么就此没有很多信息。
3 个解决方案
#1
The php client doesn't handle persistent connections. you either need to use your pooling idea, or use a 3rd party memcached client for php that supports persistent connections.
php客户端不处理持久连接。你需要使用你的池化想法,或者使用支持持久连接的php的第三方memcached客户端。
like this one:
像这个:
#2
Both pecl/memcache and pecl/memcached support persistent connections per process. However, the bug does exist in pecl/memcached at this time.
pecl / memcache和pecl / memcached都支持每个进程的持久连接。但是,此时错误确实存在于pecl / memcached中。
#3
I have read that persistent connections feature is broken in the "memcached" PHP extension.
我已经读过“memcached”PHP扩展中断了持久连接功能。
First: the "persistent" connection is not destroyed. (This is ok.)
第一:“持久”连接不会被破坏。 (还行吧。)
Second: when you try to reuse it, it creates a new one! (This is bad!)
第二:当你尝试重用它时,它会创建一个新的! (这是不好的!)
Result: memory leaks, increasingly consuming all available RAM.
结果:内存泄漏,越来越多地占用所有可用内存。
Check here: http://brian.moonspot.net/php-memcached-issues
点击这里:http://brian.moonspot.net/php-memcached-issues
As I said, I haven't experienced this myself - I just read this information in the linked article.
正如我所说,我自己没有经历过 - 我只是在链接的文章中阅读了这些信息。
#1
The php client doesn't handle persistent connections. you either need to use your pooling idea, or use a 3rd party memcached client for php that supports persistent connections.
php客户端不处理持久连接。你需要使用你的池化想法,或者使用支持持久连接的php的第三方memcached客户端。
like this one:
像这个:
#2
Both pecl/memcache and pecl/memcached support persistent connections per process. However, the bug does exist in pecl/memcached at this time.
pecl / memcache和pecl / memcached都支持每个进程的持久连接。但是,此时错误确实存在于pecl / memcached中。
#3
I have read that persistent connections feature is broken in the "memcached" PHP extension.
我已经读过“memcached”PHP扩展中断了持久连接功能。
First: the "persistent" connection is not destroyed. (This is ok.)
第一:“持久”连接不会被破坏。 (还行吧。)
Second: when you try to reuse it, it creates a new one! (This is bad!)
第二:当你尝试重用它时,它会创建一个新的! (这是不好的!)
Result: memory leaks, increasingly consuming all available RAM.
结果:内存泄漏,越来越多地占用所有可用内存。
Check here: http://brian.moonspot.net/php-memcached-issues
点击这里:http://brian.moonspot.net/php-memcached-issues
As I said, I haven't experienced this myself - I just read this information in the linked article.
正如我所说,我自己没有经历过 - 我只是在链接的文章中阅读了这些信息。