php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59434 binary protocol get() unexistant key delay
Submitted: 2010-09-22 05:41 UTC Modified: -
Votes:4
Avg. Score:4.2 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mglyebov at gmail dot com Assigned:
Status: Open Package: memcached (PECL)
PHP Version: 5.3.2 OS: centos 5.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-09-22 05:41 UTC] mglyebov at gmail dot com
Description:
------------
If binary protocol is enabled
>>$mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
then every $mc->get('some_unexistant_key') produces delay of 
about 40ms.


System Configuration:
$>umane -a
  Linux some.name 2.6.18-194.3.1.el5.028stab069.6 #1 SMP Wed 
May 26 18:31:05 MSD 2010 x86_64 x86_64 x86_64 GNU/Linux
$>memcached -h
  memcached 1.4.5

phpinfo()
PHP Version 5.3.2
memcached
  memcached support	enabled
  Version	1.0.2
  libmemcached version	0.43
  Session support	yes
  igbinary support	yes


Reproduce code:
---------------
        $mc = new Memcached();
        $servers = array(array('memcache1', '11211', '100'));
        $mc->addServers($servers);

        $probe_key = 'unexistant_key';

        echo '<br/>NOT using Memcached::OPT_BINARY_PROTOCOL<br/>';
        $mc->setOption(Memcached::OPT_BINARY_PROTOCOL, false);

        $start = microtime(true);
        for ($i=0; $i<100;$i++)
            $mc->get($probe_key);
        $stop = microtime(true);
        echo ($stop - $start).' sec';


        $mc->setOption(Memcached::OPT_BINARY_PROTOCOL, true);
        echo '<br/>Using Memcached::OPT_BINARY_PROTOCOL<br/>';

        $start = microtime(true);
        for ($i=0; $i<100;$i++)
            $mc->get($probe_key);
        $stop = microtime(true);
        echo ($stop - $start).' sec';


Expected result:
----------------
NOT using Memcached::OPT_BINARY_PROTOCOL
0.012768983840942 sec
Using Memcached::OPT_BINARY_PROTOCOL
0.01xxxxxxxxxxxxx sec

Actual result:
--------------
NOT using Memcached::OPT_BINARY_PROTOCOL
0.012768983840942 sec
Using Memcached::OPT_BINARY_PROTOCOL
4.0627429485321 sec

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-12 11:14 UTC] quentin389 at gmail dot com
Use memcached option TCP_NODELAY, that will fix the 30-40ms delays on non-existing keys and drop them to what you get for other keys (<1ms)
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 00:01:26 2019 UTC