Dustin: I don't know if putting the code that I have written and also
the way I start memcached demon would help you guys figure out whats
causing this, but still I would post it for your perusal.
function array_diff_fast($data1, $data2) {
$data1 = array_flip($data1);
$data2 = array_flip($data2);
foreach($data2 as $hash => $key) {
if (isset($data1[$hash])) unset($data1[$hash]);
}
return array_flip($data1);
}
$req=explode(";",$_SERVER['QUERY_STRING']);
$sizestr=$_REQUEST['sz'];
$sizes = explode(",",$sizestr);
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");
foreach ($sizes as $sz) {
$get_result = $memcache->get('inclarr');
if(!empty($get_result)){
$incl_array = unserialize($get_result);
}
else
{
$get_result = file_get_contents($path.'/data/incl_'.
$sz.'.ser');
$memcache->set('inclarr', $get_result);
$incl_array = unserialize($get_result);
}
$incl_key_array = array_keys($incl_array);
$incl_req_filter = array_intersect($req, $incl_key_array);
if (!empty($incl_req_filter)) {
foreach($incl_req_filter as $key) {
if (!empty($incl_array[$key])) {
$include_array[$sz][$key] = $incl_array[$key];
}
}
}
$get_result = $memcache->get('exclarr');
if(!empty($get_result)){
$excl_array = unserialize($get_result);
}
else
{
$get_result = file_get_contents($path.'/data/excl_'.
$sz.'.ser');
$memcache->set('exclarr', $get_result);
$excl_array = unserialize($get_result);
}
$excl_key_array = array_keys($excl_array);
$excl_req_filter = array_intersect($req, $excl_key_array);
if (!empty($excl_req_filter)) {
foreach($excl_req_filter as $key) {
if (!empty($excl_array[$key])) {
$excl_key_array = $excl_array[$key];
foreach($include_array[$sz] as $key=>$value) {
$include_array[$sz][$key] = array_diff_fast($value,
$excl_key_array);
}
}
}
}
$get_result = $memcache->get('keymatcharr');
if(!empty($get_result)){
$fixed_match_cnt = unserialize($get_result);
}
else
{
$get_result = file_get_contents($path.'/data/
keyd_match_cnt_data.ser');
$memcache->set('keymatcharr', $get_result);
$fixed_match_cnt= unserialize($get_result);
}
$cntarr = $include_array[$sz];
if(!empty($cntarr))
{
foreach($include_array[$sz] as $key=>$value) {
foreach($value as $key_id) {
$largest = max($fixed_match_cnt[$key_id]);
if(!empty($testkey_match[$key_id])) {
if($largest > $testkey_match[$key_id]) {
$testkey_match[$key_id]++;
}
}
else
$testkey_match[$key_id] = 1;
}
}
}
}
arsort($testkey_match);
foreach($testkey_match as $key=>$value) {
for($k=0; $k < count($fixed_match_cnt[$key]); $k++) {
if ($value == $fixed_match_cnt[$key][$k]) {
if (!in_array($key, $final_array)) {
$final_array[] = $key;
}
}
}
}
and here is the command that I use to start memcached
/usr/local/memcached/bin/memcached -u root -d -c 4096 -n 8192 -b 2048
Size of data in memory : 15.3 KBytes
Size of memcached cache size: 64 Mb
-- apache bench results
Concurrency Level: 200
Time taken for tests: 33.716885 seconds
Complete requests: 10000
Failed requests: 47
(Connect: 0, Length: 47, Exceptions: 0)
Write errors: 0
Total transferred: 8112328 bytes
HTML transferred: 2041164 bytes
Requests per second: 296.59 [#/sec] (mean)
Time per request: 674.338 [ms] (mean)
Time per request: 3.372 [ms] (mean, across all concurrent
requests)
Transfer rate: 234.96 [Kbytes/sec] received
Please let me know if you need any more information ..
Ved