Fast writes, slow reads

Brion Vibber brion@pobox.com
Sun, 10 Aug 2003 05:18:53 -0700


Anatoly Vorobey wrote:

>What happens if you batch all the reads together, as one request?
>
I'm having trouble getting this to work... so far, it takes the same 
amount of time (plus a fraction of a second for setting up more arrays) 
but I only actually get the last item requested returned in the hash. 
This _may_ be a problem in the PHP client, or I _may_ be doing something 
wrong. I haven't been able to get it working in perl, which _may_ be 
because I can't figure out how to get anything out of a hash reference. :)

Here's the PHP code for the batched get:

$keys = array();
for($i=0; $i<$max; $i++) {
    $keys[$i] = "test:intarray:$i";
}

$res = $wgMemc->get_multi( $keys );

$arr = array();
for($i=0; $i<$max; $i++) {
    $n = $res[$key = "test:intarray:$i"];
    if($n === NULL) {
        echo "<li> $i not in cache, adding\n";
        $n = $i;
        $wgMemc->add( $key, $n );
    } else {
        echo "<li> $n found\n";
    }
}

>The slowdown must be due to something on the client side then. If you
>change the client's platform without changing the server's platform, the 
>time changes from 50 to 20 seconds, right?
>
Seems to be so, yes.

-- brion vibber (brion @ pobox.com)