I’ve recently been informed by my host that my site is causing very high server load, although I don’t really know how I can find out what is actually causing it. I tested to make sure and yes, its my site (and my coding).
The speed of the scripts is fine, and I have optimised all of 20 or so mySQL queries to less than 0.001 seconds. I use mod_rewrite quite a lot too, but I don’t see how this could cause such a rise in server load.
Is there any way of finding out whether a certain function or operation is causing the high load?
My visitor count is around 1,000 visitors per day average whom make around 35,000 pageviews. As I’ve heard from my host there are other sites on the server with this many visitors and apparently they do not incur such load.
Maybe we can help you reduce that? Personally I have 2 queries on my pages (1 for articles and 1 for categories) and I have reduced that by Caching my pages as HTML pages. Caching should definately help you, unless your data has to be truly dynamic.
Are you just moving the query into an include? If so, that defeats the purpose.
Are you using Joins in your queries effectively and also re-using your data so that you don’t need to constantly query the database. You might want to subject you table structure and queries to the MySQL forum here and see if they can help you reduce it.
petesmc: Let me make this clear: I’m not stupid (moving the query to the include, ).
I’ve already optimised the queries themselves quite a lot and thus do not take up much time and hopefully this means not much server load is generated.
Well then only thing I can think of is to move to a new server. You are serving 1 million page views a month, I think that warrants a dedicated server.
If the queries all take less than a millisecond, then 20 queries on one page should not be a problem. I would guess that the problem would be somewhere else.
If you have SSH or telnet access, you can use ab (Apache Benchmark) to test how much time each page request is taking on the server. Note that you must use the copy of ab that’s on the same server as the site itself for the results to be meaningful. Usually ab is in /usr/local/apache/bin
You would probably have to write a script to do it yourself. However you’d have to make sure that the benchmarking itself doesn’t take up huge amounts of their server load too of course
You might want to set up an Apache server on your local machine and test the whole thing on your local machine. It won’t give you an accurate idea of how well it will run on a busy shared server but it will give you an idea of how long each page takes to load.
CapitalWebHost: Yeah, I try to make use of JOINs in mySQL. I don’t think there are any more oppurtunities to use JOINs on the home page, though.
mmj: I tried to get my host to install APD though for some reason he couldn’t make it compatible. I will be able to speak with my host about using ab.
realestate: There sure is a big jump, going up by 150 uniques per day per week. Too bad I keep getting my site suspended for this load
noddy: I have quite a few mysql_fetch loops, though this has been reduced now due to caching.
There are still a substantial amount of queries on the page though they are mostly to do with sessions (not-cacheable) and the latest scores which cannot really be cached to provide the effect I need.