Poor performance

From DreamHost
Jump to: navigation, search

Overview

You may sometimes notice that your website does not perform as well as it should. The causes for poor performance are wide and varied, and this article describes some of these reasons to help you diagnose why your website might perform poorly and to provide some tips to improve it.

Optimizing your site

Markup

Make sure your web documents embody the best practices in web page development. These include, but are not limited to:

Use semantically-appropriate and valid markup 
HTML or XHTML elements should be used to describe their content. For example, a blockquote element should contain quoted text, and not be used to create a text indentation. Your documents should be validated and (where appropriate) well-formed.
Use absolute or relative paths 
When linking to local resources (images, video, JavaScript, etc.) within your documents, use either absolute (also called relative from root) or relative paths. Using a remote path (such as a URL) will cause an additional and unnecessary HTTP request.
Use CSS 
Use CSS for controlling the presentation of your documents. External CSS files are cached by the browser, reducing overall page-load times. Do not use HTML tables to control page layout (unless presenting tabulated data) because they significantly increase a document's markup footprint. When possible, external javascript and CSS files should be combined. It is always faster to load one large file than it is to load a few dozen small files.

Media

You can reduce the file size of media such as images, videos, and music by using compression techniques. Background images, particularly those that are tiled, can usually stand up to extra compression. Make use of separate image thumbnails where large images are not needed. Try to avoid high definition images on the majority of your pages. Having a megabyte or more of images will seriously slow down your site because it takes longer to download all of the site files.

Scripting

Sometimes a poorly-written script, or a script that conflicts with other site elements can lead to a slow site and poor performance. Try running a full page test at: http://tools.pingdom.com/fpt/

Any scripts that take a long time to load should be investigated to see if they can be better optimized. It may also be worthwhile to turn off any scripts that look problematic to test and see if deactivating them leads to an improved performance.

PHP

Try installing PHP_FastCGI. It keeps PHP sessions running so it doesn't have to instantiate every time someone hits your web site.

DreamHost PS users can use XCache. It caches compiled PHP code in memory for later requests.

Make sure to test all PHP scripts. PHP scripts that do not properly end can cause processes to be skipped for hitting the FCGI process limit, which can cause site slowness.

Caching

For WordPress, review the Speeding Up WordPress and Fine Tuning Your WordPress Install articles.

For MediaWiki, enabling the file cache can improve performance. Here's more info on how to enable the file cache.

You can also enable Page Speed Optimization for all of your domains.

Databases

Your MySQL database might run slowly if it has a lot of overhead. Overhead is caused by rows being deleted, leaving empty space. The more active a database is, the more overhead there may be.

You can cleanup overhead within phpMyAdmin. View the Structure of your database in phpMyAdmin. At the bottom, click 'Check tables having overhead'. Then select the pulldown 'Optimize Tables'.

You can also cleanup overhead via a shell script and/or cron job. You may want to run a monthly cron job to do this for you. A cron job entry might look like so:

#!/bin/sh
/usr/bin/mysqlcheck -o -v -u USER -p PASSWORD -h MYSQL.EXAMPLE.COM DATABASENAME;

Replace the items in all-caps with values appropriate for your site.

Make sure that spam comments are not making it take longer to access your database. Akismet is an very useful plugin for WordPress that helps you eliminate spam comments which can speed up your site.

Internet issues

Data passing between a user agent and a web server traverses the internet by means of a packet switching system that may encompass a dozen or more nodes, depending on the physical locations of the user and the web server.

Traceroute

Main article: Traceroute

One major reason for poor site performance is when one or more "hops" taken by data packets passing through the internet are obstructed or delayed. Traceroute is often used for network troubleshooting. By showing a list of routers traversed, it allows the user to identify the path taken to reach a particular destination on the network. This can help identify routing problems or firewalls that may be blocking access to a site.

ISP

Some users may suffer from a poorer performance more than others. This may be the result of problems with a particular Internet Service Provider (most often, if it is one of the large Online Service Providers, such as AOL). Network congestion, bandwidth throttling and restrictions, data discrimination and filtering, and even content filtering can all result in poor site performance.

Network issues

Nake sure to test your own local internet speed at a site such as speedtest.net. This may help to confirm where the slowness is originating.

Web server

Load, users, uptime, and so on.