At some point, when a project becomes popular, availability becomes an issue. For a client it’s important their platform (website, intranet, etc.) is up and running 99,99% of the time (actually they want it to be available 100% but no one is brave enough to guarantee such service).
People often start with hardware optimization such as installing faster hard drives, faster CPU’s, more memory, … and they’re right doing so. Hardware is tax-deductible and cheaper than hiring a developer to optimize the code source. However at some point it’s necessary to sit down and actually review the code if no options are left (except doing a major hardware upgrade).
Query optimization is obviously one of the first items looked at. Queries to a database server (often on not so fast 7200 rpm disks) slow down the whole application. Inefficient use of resources and looping or requesting the same data over and over again, not caching query results all lead up to a slow application. You definitely should take a look at those things but what else can you do?
External image hosting
You could start by using an external hosting partner to host images / photographs for you. ImageShack, Flickr, etc. are all viable services but are often bandwidth-limited or blocked by corporate firewalls. A solution for these problems is Amazon web services S3 (Simple Storage Service) which is often an inexpensive solution compared to upgrading available disk space.
HTTP compression*
This feature can be configured by tweaking the web server software – and should be enabled FIRST THING. It’s free bandwidth if you think about it. Most browsers support it and it saves you up to 66% of transferred text data which is a lot in the end. This reduction is by the way applied to all fiels served (HTML, JavaScript and CSS). If you’re working with Apache, take a look at mod_deflate.
Host RSS feeds somewhere else
If you provide RSS feeds for your content, you can choose a third-party service like FeedBurner (owned by Google). An additional bonus is that you have usage statistics for your feeds so you can track your subscribers in more detail.
Reduce content size
You can do some compression yourself by limiting the amount of data your webserver sends to a browser.
- Eliminate whitespace where possibly (but keep HTML readable)
- Compress your CSS file (CSS drive CSS compressor)
- Refactor your JavaScript code (shorter variable and functions names)
- Minify your JavaScript code (JSMin – removes unnecessary white space and comments from your JavaScript files)
These changes should make the whole experience faster though keep in mind that if you’re getting a tremendous traffic increase, the tips listed above won’t suffice but all small tweaks help.
* UPDATE: enabling mod_deflate
In order to enable mod_deflate, edit your httpd.conf file and make sure LoadModule deflate_module modules/mod_deflate.so is enabled. (if not, remove the comment character). Next find the following part in the httpd.conf file
<Directory />
Options FollowSymLinks
AddOutputFilterByType DEFLATE text/html text/plain text/css application/x-javascript
AllowOverride None
Order deny,allow
Deny from all
</Directory>
This is your root directory. Whatever you enable here is automatically active for all other path / site definitions (including virtual hosts) as well. Add the line that’s in bold type and save your httpd.conf file. Restart apache (graceful – to reload the new configuration) and monitor your access log file – it should contain additional ZIP information.
“GET /filers/storageOverview HTTP/1.1″ 1318/3971 (33%)