Your Site is slow? - Read this for performance increase!!

灰暗的星星灰暗的星星灰暗的星星灰暗的星星灰暗的星星
 
分类:技术文章

Hi,
you think your server is performing poorly and you want to improve the output speed of Joomla. This article should give you some things to check and solve to sometimes drastically enhance your servers performance. Lets make a list:

General Optimizations:

Joomla specific Optimizations


General Optimizations:
Hosting package
A lot of people out there buy a shared hosting package and expect to be able to run a site with hundreds of hits per second on that one. We have to make it clear here, that Joomla is not static HTML. You may be able to service hundreds, if not thousands of users per second with static HTML pages, but Joomla needs quite some CPU power and if you plan a site with more than about 5 hits per second, you should directly look for a dedicated server, even more hits, and you should think about a load balancing system, several servers and a MySQL cluster. There is an interesting thread on this one here. For a normal set up, look around in this forum, there are several threads with the experience of the users. Especially the experiences with different providers are very interesting.

HTML code
When you create your page, you should pay attention to two things. First, use valid code. The more bugs your code consists of, the longer a browser needs to render it. Second, use less objects. A lot of people are using to many images, flash and javascript on their site. There have been great improvements in the connection speed of a lot of users and broadband connections exceeding 1 MBit are not as uncommon as just a few years ago, but the vast majority of all users are still dial-ups with a modem or ISDN connection. If you don't want to exclude 90% of the web community, you should keep your site small. There are several services out there that can analyze your site, I will only mention the Web Page Analyzer from Websiteoptimization. For the validation of your HTML code and Javascript, I can only recommend the Web Developer Extension for Firefox. You can get it here.
These things can improve your sites speed drastically and you should really look into this!

Images
As I wrote in the previous paragraph, small is beautifull. ;) This also applies to images. Take a look at your images and see if you really need them in a resolution of this size. Wouldn't a picture with half the dpi look as good? Often people don't notice that they are using images the size of lower Manhattan because they set the size in the HTML code to something way smaller and their browser has the images in his cache, but others first have to load a huge image and then it gets reduced to the size of a stamp. This takes a lot of time for them and they don't want to wait that long. So see to a reasonable size of your images both in pixel and in bytes.
Another thing that's often slowing down the performance are missing images. If you have a reference to a non-existent file, the server will need a lot of time to notice that and answer with a 404. In some cases your server is configured that way that you are redirected to the frontpage when the server can't find the file and in that case the browser receives a complete new page each time he requests a missing file. Imagine just one page with an image that is used at a dozen places in the layout and is not present. This can slow down the delivery to up to half a minute!

PHP accelerators
If you can't afford a new server and you are on your performance limit, think about buying a PHP accelerator. There are again numerous available, like Zend or APC. Just look in this forum for further information. They can do little wonders about your performance.

Joomla specific Optimizations
Used extensions
You have installed Joomla and you have found all those neat little extensions available on extensions.joomla.org. You have installed numerous of them and think your site looks really cool, but lately you have to wait several seconds till your site pops up.
Again, this is another example of small is beautifull. Joomla needs a lot of extra time for each module or plugin it has to load. I guess you can think where this is heading: Use less extensions and try to make the best out of the few you really need.
In this regard, you should take a look at your extensions and see if any of those uses an external datasource. If your server first has to load the data from another server, process it and then send it to you, this can take up several seconds. Try to find an extension that does the same but stores the data on your server. If the other server has a failure or is getting DoSed, your server will not be affected by this, too, since it is just reading from its local data source.

Database
Great potential lies within the database. In general we recommend you to allways use the latest version of Joomla, since for example there were big improvements from 1.0.7 to 1.0.8 and there are even bigger improvements coming in 1.5. (1.0.8 uses about half as much queries as 1.0.7 and 1.5 does the same trick with about a quarter of the amount of queries from 1.0.7)
If this is not enough for you, you can also enable query caching in MySQL. This will cache a lot of queries in the RAM of your server and make it fast as a bullet, but be carefull, you really need A LOT of RAM. 2 GByte is not uncommon and more like the lower starting point for this. This is nothing for shared hosting!

Debugging your site
I also recommend switching on error reporting in PHP and setting it to its highest setting. You will probably have to correct some errors in the code to get them all away, but they, too, are wasting precious CPU time and therefore performance.
If you switch on debugging in the Joomla backend, you get a list of all queries executed for this site in the frontend. If you see a number thats to high, you should hunt those down and see what can be done about reducing that number.

SEF/SEO
Last but not least we have SEF/SEO. This takes a lot of CPU power and if you have problems with your server, you should switch that off as the first emergency measure. Due to some errors in erlier Joomla versions, SEF sometimes produced dozens or even hundreds of useless queries.

With these things you should have your server going a lot faster than previously. If you still have problems, please post into this board and we will try to give you specific help on this one.