Persistent connections to memcached in PHP

jW. picture jW. · Jun 11, 2009 · Viewed 16.2k times · Source

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?

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

$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.

Answer

brianlmoon picture brianlmoon · Jul 29, 2010

Both pecl/memcache and pecl/memcached support persistent connections per process. However, the bug does exist in pecl/memcached at this time.