Memcache vs APC for a single server site data caching

Viewed 13029

I have a single server site thats pushing 200k unqiues per day, and the traffic doubles roughly every 40 days (for the last 5 months anyway).

I pretty much only plan to cache the output of mysql_query functions for an hour or so. If cache is older than that, run query, put result back into the cache for another hour.

My mysql DB is about 200mb in size (grows by maybe 10-20mb/month).

Im doing a lot of file caching by writing HTML outputs and using them for a few minutes, and then regenerating the html.

Unfortunately, since its a database site, that allows for many sorting, searching and ordering methods, as well as pagination.... there are over 150,000 cached pages. Im also not caching the search queries, which cause most of the load.

I'd like to implement a caching system, and I wanted to know which one is faster. Would love to see some benchmarks.

6 Answers

in my case apc is 59 times faster than memcache

<?php
ini_set('apc.enable_cli','1'); //if u run in cli you may need to do changes in php.ini
error_reporting(E_ALL);
$mem=new Memcache();
$mem->connect('127.0.0.1',11211);
$mem->replace('testin','something');
$i=0;
$time=time()+microtime();
apc_store ( 'testin','something');
$num=1000000;
while($i<$num){
 $mem->get('testin');
$i++;
}
echo "memcache took: ",time()+microtime()-$time," for 1 million gets","\n";
$time=time()+microtime();
$i=0;
print_r(apc_fetch('testin'));
while($i<$num) {
apc_fetch('testin');
$i++;
}
echo "apc took: ",time()+microtime()-$time,"for 1 million gets \n";

here is the output

memcache took: 37.657398939133 for 1 million gets
somethingapc took: 0.64599800109863for 1 million gets
Related