[memcache/PECL] Performance problems with set & data over 8KB
| From: | Jean-François Bustarret | Date: | Fri, 31 Mar 2006 08:06:27 +0000 |
| Subject: | [memcache/PECL] Performance problems with set & data over 8KB | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-3678@lists.php.net to get a copy of this message | ||
I have major scalabity problems (very high load with 100 or 200 memcache
read/writes per sec) using memcached (PECL 2.0.0/PHP 5.0.5 client).
It looks like I have a problem writing data over 8KB...Here is a test script
:
<?php
$memcache_obj = memcache_connect("localhost", 11211);
for ($step=6; $step < 10; $step++) {
$key=md5(uniqid(rand()));
$value = str_repeat(md5(uniqid(rand())), $step*1024/32);
printf("\n%d KB : ", strlen($value)/1024);
$start = microtime(true);
for($i=0;$i < 1000 ; $i++)
$memcache_obj->set($key, $value, 0, 0);
$end = microtime(true);
printf(" %d set/s", 1000/($end-$start));
$start = microtime(true);
for($i=0;$i < 1000 ; $i++)
$var = $memcache_obj->get($key);
$end = microtime(true);
printf(" %d get/s", 1000/($end-$start));
}
?>
The results are :
6 KB : 14197 set/s 15549 get/s
7 KB : 13367 set/s 15287 get/s
8 KB : 24 set/s 13332 get/s
9 KB : 24 set/s 13198 get/s
With a 1 byte increment, the results are :
[...]
8143 B : 13590 set/s 13089 get/s
8144 B : 24 set/s 13279 get/s
[...]
Doing a strace -r T shows this :
[...]
0.039552 recv(3, "STORED\r\n", 8192, 0) = 8 <0.000045>
0.000143 send(3, "set d7e283883d2316ba14484df6d73c"..., 8192, 0) = 8192
<0.000088>
0.000178 send(3, "baf9272ea0a2ad667cdc45df3c767674"..., 49, 0) = 49 <
0.000046>
0.000129 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP, revents=POLLIN}],
1, 1000) = 1 <0.039473>
0.039562 recv(3, "STORED\r\n", 8192, 0) = 8 <0.000045>
[...]
On the memcache daemon, the strace is :
[...]
0.000108 write(7, "STORED\r\n", 8) = 8 <0.000046>
0.000126 setsockopt(7, SOL_TCP, TCP_CORK, [0], 4) = 0 <0.000096>
0.000168 read(7, "set e3888bfaae66969d52b1a37b8745"..., 16384) = 8192 <
0.000047>
0.000128 read(7, 0x805a3d0, 8192) = -1 EAGAIN (Resource temporarily
unavailable) <0.000043>
0.000135 setsockopt(7, SOL_TCP, TCP_CORK, [1], 4) = 0 <0.000045>
0.000133 read(7, 0xb779901d, 1073) = -1 EAGAIN (Resource temporarily
unavailable) <0.000044>
0.000112 gettimeofday({1143792299, 307963}, NULL) = 0 <0.000043>
0.000113 gettimeofday({1143792299, 308075}, NULL) = 0 <0.000043>
0.000114 epoll_wait(0x4, 0x8050280, 0x400, 0x989) = 1 <0.038448>
0.038519 gettimeofday({1143792299, 346709}, NULL) = 0 <0.000044>
0.000115 read(7, "26f8ea48f7b44f912142e6cba0026063"..., 1073) = 1073 <
0.000051>
0.000133 time(NULL) = 1143792299 <0.000043>
0.000108 time(NULL) = 1143792299 <0.000043>
[...]
Does someone have a clue ?
--
Jean-François Bustarret
http://www.jeuxdecartes.net