View Full Version : Ways to reduce server load / turn on top level caching
Our Shop Window appears to be taking a huge toll on the server and we are looking at ways in which we can reduce this.
We have turned on the smarty caching which helps but could do with some more improvement. We noticed the top level cache folder which is empty (this is not the same as the smarty cache folder) suggesting another level of caching possible? Any suggestion on how to turn this on or any other ways in which to reduce the server load will be appreciated.
Cheers
Hi slashdot
Im having the same issues and have been experimenting with the caching...
I've changed the line in the root index.php script from:
//$oSmarty->cache_lifetime = 60;
to:
// Clear the smarty cache for docs older than 1.001 days
$oSmarty->clear_all_cache(86500);
// Iincreased cache time from 1 mins to 24 hours
$oSmarty->cache_lifetime = 86400;
We noticed the top level cache folder which is empty (this is not the same as the smarty cache folder)
please elaborate... is there a batter way to chache these pages at hand so that i can cull by calls?
Thanks
S
I appear to be having a similar problem.
My web host has contacted me to say that the client software is causing such a drain on the shared server I am on, that they have had to move me off of it & will terminate my hosting unless I switch to a managed/dedicated server!!
There is no way I can afford this, so I need to know how to work round this problem. They've said "productlist.php is causing CPU load."
I have a month to get this resolved, so would appreciate a response from Affiliate Window on this!!
by accessing productlist.php, you could be using many different sets of files with many different output results. I would imagine they've picked on that file because a large percentage of your usage will have productlist.php in the URL. The problem could well be within any of the included files. Ask your host for a list of the problem URLs, not just the file that outputted them.
first job would be to look at your error logs. Note down your own IP address then access a page. Check your error logs for any errors generated by you on that page access.
There WILL be errors, guaranteed. Theres a good chance alot of these would be warning" rather than fatal errors. These will most likely be "Undefined index" errors.
To fix these, do sanity checks before going into loops
for instance:
foreach($something as $other){
#do something
}
if $something should be an array use:
if(is_array($something)){
foreach($something as $other){
#do something
}
}
or if it's an object, use:
if(is_object($something)){
foreach($something as $other){
#do something
}
}
Basically, this will bypass the loop if there's nothing to loop over, which will stop the errors (or warnings) therefore cutting down on CPU usage.
If you have any bespoke code in productlist.php, check it again.
If you have any database connections, make sure that you close the connection with mysql_close().
Check that any bespoke loops have an end.
Try and find a cleaner way to write any of your bespoke code. Less code tends to mean less time to execute. Look up microtime() so you can see how long each part of your code execution takes.
basically, all you can do is check the code against your error logs and find what's making the cpu stick.
Choice of host could be a factor too. If you're on webmania, then there's your problem right there.
Caching outputted pages would definitely help, but if you have errors in the code, all caching would do is cut down on the number of times that code was executed. Yeah it'd cut CPU usage, but wouldnt fix the problem.
Fix it, then look up My.Cache.php (http://www.phpclasses.org/browse/file/16052.html) . you'll need to register to get it.
Hmmm, unfortunately 1and1 don't provide access to Apache error logs on shared hosting packages for technical reasons!!
I'm adding some code to the individual pages to generate error logs & will see what happens
acorndomains.co.uk
21-05-09, 09:19
My sites are creating huge error log files and making thousands of "%%%product.tpl" files in the Smarty/cache folder.
What are these cached files for and can I turn them off? How do I do that?
Thanks
My sites are creating huge error log files and making thousands of "%%%product.tpl" files in the Smarty/cache folder.
What are these cached files for and can I turn them off? How do I do that?
Thanks
There's a slight problem with Smarty caching not cleaning itself. Ollie posted a fix here:
http://www.shopwindowforum.com/showthread.php?t=908&highlight=smarty+cache
If you want to turn it off, Simply change the Cache time to '0' in all your php files. Wont make much difference anyway, Smarty caching doesn't seem to make much difference to speed.