Zend App Optimizing
Well, I have my alpha testing version of my Zend application done. Other than more changes coming, I need to optimize it because it's ridiculously slow right now.
1. Metadata cache. Describe table costs 5-6 ms even on a small indexed table. Add the following to the Bootstrap file. Now the metadata cache is enabled and describe table command is gone.
$frontend= array(
'lifetime' => 7200, //2 hours
'automatic_serialization' => true
);
$backend= array(
'cache_dir' => './tmp/',
);
$cache = Zend_Cache::factory('core',
'File',
$frontend,
$backend
);
Zend_Registry::set('cache',$cache);
Zend_Db_Table_Abstract:: setDefaultMetadataCache($cache) ;
I don't have many static pages. So I'm only caching the products listing page. Add the following to the getProductByCategory function
$cache = Zend_Registry::get('cache');
if(!$result = $cache->load('products_in_'.$category))
{
debug( 'caching the data...');
$select = $this->select();
$select ->where("category=?", $category);
if (true === is_array($order))
{
$select->order($order);
}
$rows = $this->fetchAll($select);
if (!$rows) {
debug("Could not find rows with category $category");
return FALSE;
}
$cache->save($rows->toArray(), 'products_in_'.$category);
return $rows->toArray();
}
else
{
return $result;
}
this article is interesting, I'll keep it in mind.http://zfsite.andreinikolov.com/2008/08/zend_db_table-time-overhead-about-25-percents/
2. Server CPU intensive even on the login page ---
-- install eAccelerator -- now the site is at least twice as fast. Still like it to be faster.
3. Client side. My app is slow enough that I used it as bench test on different browsers. Speed: IE9 > Chrome (slightly)>Opera >> Firefox.