News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Reducing CPU usage

Started by orange, April 28, 2005, 03:31:46 PM

Previous topic - Next topic

orange

My host has told me that my forum is using an unacceptably high amount of the server CPU, and if I don't reduce it they will have to terminate my account.

My forum isn't particularly big -- about 110,000 posts with 250 posts per day, and about 40 users online at a time.

I already have the search feature disabled because of previous slow loading problems.

Any tips for what else I can disable to speed it up? It seems to be the PHP scripts themselves that are causing the problems, because my host says it's Apache and not the MySQL server that is causing the high load.

Are there any bits of functionality I could easily disable that would have a noticable effect on the speed of the forum?

Ben_S

Ask them to provide proof you are using the resources they say you are.
Liverpool FC Forum with 14 million+ posts.

orange

They have done, Apache Extended Status is enabled and when I disabled the forums the CPU load fell from 7% to 1%.

They say 7% is unacceptably high for a shared hosting account, which I can understand because they probably have around 100 sites per server.

Is there any way I can trim even a couple of percent off the load? Would disabling features like the calendar help?

Why does viewing a topic need 16 queries to generate the page?

Ben_S

40 Users online is pratically nothing, I currently have 374 online (although that is in a 30 min period - for 15 mins it is just under 270) and my server load is 0.32.

SMF is fairly well optimized, do you have any mods installed?

Did your host really express the server load as a percentage or just a number?
Liverpool FC Forum with 14 million+ posts.

orange

I don't have any mods installed, no, just a plain SMF 1.0.2

My host expressed it as a percentage, but I have access to the Apache Status page, which was displaying loads of 5-7% with the forums online, reducing to about 1% after I disabled them.

While 7% CPU load would be negligible on a dedicated server, they point out that on a shared hosting account that is well above my fair share.

I'm currently running MySQL 3.23 -- would upgrading to version 4 make any significant difference to performance?

Ben_S

SMF is highly optimized for MySQL 4 and tends to run quite slow on 3x.
Liverpool FC Forum with 14 million+ posts.

orange

Ok, I've tried that and it seems to have helped a bit.

Is it worth disabling output compression? Does the gzipping of the output add a significant amount of processing time to the page loads? I have plenty of bandwidth to spare so this shouldn't cause a problem.

[Unknown]

Output compression does take a bit, but not that much.  I suggest leaving it on, because it will make requests shorter (less work sending data.)

What versions of PHP and MySQL are you using?  Any accelerators?  If you don't know, can you post a phpinfo?  What is phpinfo.php?

Do you have shell access, at all?

-[Unknown]

Midgard

Are you using Zend Optimizer?

orange

PHP 4.3.10 + Zend Optimizer 2.5.7
Just upgraded to MySQL 4.1.9

I do have shell access.

If it helps the phpinfo is here.

[Unknown]

Zend Optimizer is really just a tool that runs Zend Encoder-encoded PHP scripts.  It does improve performance of PHP slightly, but only by a negligable amount.

Using something like eAccelerator, APC, or Turck MMCache will decrease your CPU noticeably.  Basically, they cache the compiled and optimized output bytecode of a PHP script, and put it in ram.  This is then read from the ram, not the disk, which is obviously faster - but it also doesn't have to regenerate it, which is also faster.

PHP 4.3.11 is out, too, and it fixes more than one security issue.  Good idea to upgrade if at all possible.

Being that you're on a shared server, you may not have control over these things.

You may wish to consider converting some of your tables to InnoDB.  This will require that MySQL is actually set up to efficiently deal with InnoDB tables, but if it is, it will be faster.

-[Unknown]

HoTmetal

I'd look for a new host. Even if you fix these issues, you site will grow & you'll be in predicament latter down the line...

orange

Quote from: [Unknown] on May 01, 2005, 01:10:46 PM
Using something like eAccelerator, APC, or Turck MMCache will decrease your CPU noticeably.  Basically, they cache the compiled and optimized output bytecode of a PHP script, and put it in ram.  This is then read from the ram, not the disk, which is obviously faster - but it also doesn't have to regenerate it, which is also faster.

Interesting, I always thought that was what Zend Optimizer did.
Thanks for the ideas -- I checked out the websites for those utilities, but none of them seemed to have been tested with a PHP version later than 4.3.4, which makes me a bit nervous about using them with the latest version. Still, it's something to try perhaps.

Quote
You may wish to consider converting some of your tables to InnoDB.  This will require that MySQL is actually set up to efficiently deal with InnoDB tables, but if it is, it will be faster.

Interesting, thanks for your help.

QuoteI'd look for a new host. Even if you fix these issues, you site will grow & you'll be in predicament latter down the line...

Yeah, I've been starting to think that. The thing is that one step up from a shared server seems to be semi-dedicated, which involves quite a leap in price and so it's not something to take lightly.

Ben_S

Quote from: orange on May 01, 2005, 02:10:39 PM
Interesting, I always thought that was what Zend Optimizer did.
Thanks for the ideas -- I checked out the websites for those utilities, but none of them seemed to have been tested with a PHP version later than 4.3.4,

They work fine, I beleive Turck or eAccelerator is in use here and this site uses PHP 4.3.11, likewise I use Turck on my server on 4.3.11, although at some point I'll switch to eAccelerator as Turck has pretty much been abandoned.
Liverpool FC Forum with 14 million+ posts.

HoTmetal

Quote
Yeah, I've been starting to think that. The thing is that one step up from a shared server seems to be semi-dedicated, which involves quite a leap in price and so it's not something to take lightly.

You can run a pretty big site on a shared server. Check the webhosting board at SMF. there are planty of good hosts....

[Unknown]

We use eAccelerator here, and previously used Turck MMCache.  The page load times and load averages noticed the difference.

-[Unknown]

orange

Thanks for the recommendation of eAccelerator ... I installed it, and the load dropped from 7% to 1%, which my host is very happy with.

That's one very handy utility indeed :)

Advertisement: