PHP pecl / memcached extension is slow when setting parameter for sequential hashing

Using the new pecl / memcached PHP extension. Calls to Memcached :: setOption () like;

$m = new Memcached();
$m->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);

cost from 150 to 500 ms - just making a call to setOption (), and since we do not use persistent connections, but rather, we do this for every request, it hurts.

We go deeper by setting Memcached :: OPT_DISTRIBUTION to Memcached :: DISTRIBUTION_CONSISTENT, ending with the call update_continuum () in libmemcached, which looks pretty intense, although we only transfer a list of 15 memcached servers, so it’s somewhat surprising to see the continuum data structure to be restored from 150 to 500 ms

It is impossible to set this option only for persistent connections when it called only once when creating the initial connection? Or is it a libmemcached error?

Using the new pecl / memcached 1.0.1 extension with libmemcached 0.38

Thank.

+5
source share
2 answers

libmemcached 0.38 is pretty old at the moment. So pecl / memcached 1.0.1. Could you try the blucci / memcached 2.0.0b1 release from github?

+2
source

The same problem with pecl / memcached 2.2.0 (the last of PECL since writing). The only solution for me was to switch from DISTRIBUTION_CONSISTENT to:

$memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcached->setOption(Memcached::OPT_REMOVE_FAILED_SERVERS, true);

Everything seems to be fine:

var_dump($memcached->getServerByKey($key)['host']);
// string '192.168.56.1' (length=12) <== dead host

$memcached->set($key, $result, 3600);

var_dump($memcached->getServerByKey($key)['host']);
// string '127.0.0.1' (length=9) <== working host

var_dump($memcached->getLastErrorMessage());
// string 'SUCCESS' (length=7)
0
source

All Articles