I played a little with another memcached library and the plugin version to provide real stability between the PHP memcache client and the memcached server.
The problem is that the connections are still opening and closing, so the connection counter is increased instead of reusing the existing persistent connection.
I compiled a memcached daemon from the newest source on a redhat machine. I am using memcached-1.4.14 and start with "# / opt / memcached / bin / memcached -vvvv"
The php plugin I also compiled from the latest source version of memcached-2.0.1, I compiled it with libmemcached-1.0.9 to update it. It does not currently compile in libmemcached-1.0.10.
My PHP script looks like this:
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
$key = "key_" . uniqid();
$memcached = new Memcached( 'persistent' );
$memcached->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$memcached->setOption(Memcached::OPT_RECV_TIMEOUT, 1000);
$memcached->setOption(Memcached::OPT_SEND_TIMEOUT, 3000);
$memcached->setOption(Memcached::OPT_TCP_NODELAY, true);
$memcached->setOption(Memcached::OPT_PREFIX_KEY, 'persistent');
if( !count($memcached->getServerList() ) )
{
$memcached->addServer( 'localhost', 11211 );
}
$memcached->set($key, 'value');
$value = $memcached->get($key);
print_r( $memcached->getStats() );
?>
script , , .
Array ( [@ qVG:11211] => Array ( [pid] => 3728 [uptime] => 73 [threads] => 4 [time] => 1343813688 [pointer_size] => 64 [rusage_user_seconds] => 0 [rusage_user_microseconds] => 6998 [rusage_system_seconds] => 0 [rusage_system_microseconds] => 31995 [curr_items] => 37 [total_items] => 37 [limit_maxbytes] => 67108864 [curr_connections] => 38 [total_connections] => 47 [connection_structures] => 39 [bytes] => 3589 [cmd_get] => 37 [cmd_set] => 37 [get_hits] => 37 [get_misses] => 0 [evictions] => 0 [bytes_read] => 3267 [bytes_written] => 39458 [version] => 1.4.14 ) )
, , , .
tcp 0 0 ::1:11211 ::1:55941 VERBUNDEN
tcp 0 0 ::1:55961 ::1:11211 VERBUNDEN
tcp 0 0 ::1:55959 ::1:11211 VERBUNDEN
tcp 0 0 ::1:11211 ::1:56005 VERBUNDEN
...and so on
, , :
...
<43 get persistentkey_5018f83903ded
> FOUND KEY persistentkey_5018f83903ded
>43 sending key persistentkey_5018f83903ded
>43 END
...
memcache , amout Apache. , ?
:
- Red Hat Enterprise Linux Server release 6.2 ()
- PHP 5.3.3
- Apache/2.2.15
- Memcache 1.4.14
- libmemcached 1.0.9
- PHP memcached plugin 2.0.1