[announce] php: mcache extension 1.0

John McCaskey johnm at klir.com
Wed Jan 19 17:46:06 PST 2005


Here are some benchmarks I ran this afternoon.  The hardware is a Dell
2650 rackmount server running Debian Linux.  Kernel is 2.6.10.  CPU's
are dual Xeon 3 ghz.  First I benchmarked libmemcache in c directly,
then I repeated the same test with the PECL php client, and my new php
client based of libmemcache... results below:

Benchmarking libmemcache in c directly...
Performed 40000 sets in 2.248915 seconds.
Performed 40000 gets in 2.234578 seconds.
Performed 20000 gets of 2 values at once in 1.205434 seconds.

Benchmarking libmemcache based mcache client...
Performed 40000 sets in 2.4422888755798 seconds.
Performed 40000 gets in 2.5485188961029 seconds.
Performed 20000 gets of 2 values at once in 1.390410900116 seconds.

Benchmarking PECL memcache client...
Performed 40000 sets in 2.7436048984528 seconds.
Performed 40000 gets in 2.7501339912415 seconds.
Performed 20000 gets of 2 values at once in 1.6945209503174 seconds.

As you can see they are all very fast, unsuprisingly libmemcache
directly is the fastest, and the PECL client is slightly slower than my
php extension based off libmemcache.  Performance should be 'good
enough' using any of them though, I don't think the difference is enough
to get worked up over.

I'll be putting up a website with documentation as well as these results
and the source code for my benchmarks later tonight or tommorow.


On Tue, 2005-01-18 at 22:42 -0800, John McCaskey wrote:
> Adam,
> 
> The extension can be compiled in statically just like the PECL one,
> the basic steps should be:
> 1) Extract inside of php-x.x.x/ext/ directory
> 2) run ./buildconf from base of php source dir (may tell you to use
> --force if you are using a release package)
> 3) run ./configure 'all your normal options'
> --with-mcache=/path/to/patched/libmemcache/source
> 4) make
> 5) make install
> 
> Let me know if you try this and have problems, it works for me.
> 
> I'd also like to see more benchmarks myself :) I'll do some when I
> have time, the big feature of this client over the current PECL one is
> that it supports multiple servers, that alone may increase performance
> substantially if you have a cluster of servers.
> 
> As for docs, completely agree... I'll get around to it before too
> long.
> 
> John
> 
> 
> -----Original Message-----
> From: Adam Michaels [mailto:adam at digitalagemedia.net]
> Sent: Tue 1/18/2005 10:39 PM
> To: John McCaskey
> Cc: memcached at lists.danga.com
> Subject: Re: [announce] php: mcache extension 1.0
> 
> [announce] php: mcache extension 1.0Hey John,
> 
> Glad to see you've made some progress with this. I use the PECL
> extension and would be happy to
> use something based off of Sean's libmemcache. Can this extension be
> compiled in statically like the
> PECL extension?
> 
> I'd also like to see some more benchmarks when you get a chance.
> Documentation included inside the source tarball would be helpful as
> well, a README or INSTALL file.
> 
> Thanks.
>   ----- Original Message -----
>   From: John McCaskey
>   To: John McCaskey ; memcached at lists.danga.com
>   Cc: Sean Chittenden
>   Sent: Tuesday, January 18, 2005 10:33 PM
>   Subject: [announce] php: mcache extension 1.0
> 
> 
>   See attached source code.
> 
>   Unfortunately libmemcache uses the "%hu" and "%zu" format specifiers
> which at least on my box (linux 2.6.10, php 4.3.10) break inside of
> php extensions for some reason, so to make this actually compile you
> must patch your libmemcache 1.2.0 source to just use "%u", use the
> attached patch file for this.
> 
>   Then to install the extension follow the below steps after
> extracting:
>   $ phpize
>   $ ./configure --with-mcache=/path/to/patched/libmemcache/source/
>   $ make
>   $ make install
> 
>   then add mcache.so to your php.ini.
> 
> 
>   You can look at the following examples for usage, or view the
> mcache.c file which has PECL standard comments about the functions.
> 
>   <?php
> 
>   $mc = memcache();
> 
>   $mc->add_server('127.0.0.1', '11211');
>   $mc->add_server('127.0.0.1', '11212');
> 
>   $mc->set('key1', 'value_one');
>   $mc->add('key2', 'value_two');
>   $mc->replace('key2', 'two_value');
> 
>   // This returns FALSE on miss
>   $val = $mc->get('key1');
> 
>   // This returns an associative array with
>   // an entry for each key found, a miss will simply result
>   // in no entry in the array for that key.
>   $val = $mc->get(Array('key1', 'key2'));
> 
>   $mc->delete('key1');
> 
>   ?>
> 
>   Thats the basics, the remaining supported commands are: stats, incr,
> decr, flush_all, which should be pretty easy to figure out.
> 
>   Please feel free to send feedback and/or bug fixes :)  This is my
> first php extension although I'm experienced in both php and c,
> writing primarily c code lately.  So I wouldn't be shocked to find
> that I haven't done everything perfectly.
> 
>   Oh, and finally a note on licensing, I've left in the php header
> which claims the code is subject to the php license.  I'm not sure how
> the php license works and if I can change it freely to whatever
> license I want or what.  I basically don't care what you do with this,
> feel free to use it and make changes, redistribute, use in commercial
> projects, whatever.  If you are concerned about the license feel free
> to contact me.
> 
>   --
>   John A. McCaskey
>   Software Development Engineer
>   Klir Technologies, Inc.
>   johnm at klir.com
>   206.902.2027
> 
> 
> 
> 
> 
> 
-- 
John A. McCaskey
Software Development Engineer
Klir Technologies, Inc.
johnm at klir.com
206.902.2027


More information about the memcached mailing list