PHP pecl/memcached extension slow when setting option for consistent hashing

Posted by HarryF on Stack Overflow See other posts from Stack Overflow or by HarryF
Published on 2010-05-17T20:08:24Z Indexed on 2010/05/17 20:10 UTC
Read the original article Hit count: 393

Filed under:
|

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

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

are costing between 150 to 500ms - just in making the call to setOption() and as we're not using persistent connections but rather doing this on every request, it hurts.

Delving deeper, setting Memcached::OPT_DISTRIBUTION to Memcached::DISTRIBUTION_CONSISTENT ends up calling update_continuum() in libmemcached which appears to be fairly intensive, although we're only passing a list of 15 memcached servers in, so somewhat surprising to see it take between 150 to 500ms to rebuild the continuum data structure.

Could it be setting this option is only suitable for persistent connections, where it's called only once while making the initial connection? Or is this a bug libmemcached?

Using the newer pecl/memcached extension 1.0.1 with libmemcached 0.38

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about memcached