Causes of High Server Load

Hello,

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?

Are you considering the fact that it could be lots of visitors?

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.

IS that 20 queries on ONE page??

Err yes. I could probably reduce it to 15 but that would replaced by some extra include()s.

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.

Yeah I’m caching a lot now, but I’m having to include() the cached components. Is this faster/lighter on the server?

Including isn’t too intensive. Well if you have only a few it’s ok. But it looks like that 20 query page could be the problem.

Ask you host whether the server load is due to mysql or just in general (ie. because of many page views to php, etc).

I have quite a lot of includes–more than queries, however, my host has suggested the problem could be to do with mySQL.

I’ve reduced the amount of queries to 9 average now, but most have been replaced with a new include.

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, :lol: ).

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.

Joins are your friend. Learn them. Use them. See the Join. Feel the join. BE the join!!

:slight_smile:

Image handling is also a HUGE {$server load}++'er… If you are using GD or IM anywhere ensure you cache EVERYTHING you make iwth it.

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

ab -n 100 http://www.example.com/

That command will request http://www.example.com/ 100 times, and come up with an average load time per request.

It is the median time that is most meaningful on a crowded server. I’d try to keep it below 100 ms (0.1 seconds) per page request.

mmj, and how do you do it if you don’t have telnet access?

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 :wink:

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.

There is a big traffic jump on arcadexl.com according to alexa.

Have you got a lop off loops ot repeative actions happening?

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 :frowning:

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.