I find Drupal modules addicting - they can add an amazing amount of functionality to a site. The problem is that I (and my clients) often get addicted to adding more and more modules once they get the hang of what their Drupal site can do and it's hard to stop. The real cost is the performance it puts on your site.
A huge thanks goes to Khalid of 2bits.com for offering some great advice and pointing me in the right direction in this performance tweaking. He's an amazing asset to the global Drupal community let-alone the work he puts into our local Drupal Group.
One solution was to increase the hosting plan...this suggestion was made by my hosting company that was complaining on the load of one of my sites on their $10/month shared server. I figured that this was just their canned response to upsell me. I bit at it as they were threatening to cut off the domain. My problems weren't solved tho so I knew it had to be the Drupal site. I now have a hefty managed 512MB VPS that I would hope could host a number of my sites while still giving me the ssh access but the server's OS is managed by my provider
Here's what I did...
A) Got 2bits to take a look at my site and offer suggestions. Three main things were found:
- lots of modules were added. No surprise to me. I can't go to the client and ask him to reduce the functionality of his site.
- database performance is fine - whew!!! That was a relief
- Drupal overhead - I KNEW this was it...and was glad Khalid confirmed it. His main suggestion was to install Yslow. It's my new best friend! It broke down the bottle-necks of my site, rated me and gave me direct links to what Yahoo suggest to optimize your site. I paired that with lots of Google searches on their tips with adding 'Drupal' to the different Yslow sections and found lots of much needed help.
B) 2bits first recommended getting my provider to install APC on my VPS. This first step reduced my home page load time by almost half. That was a big step but I still wasn't happy...
C) One module I know is evil expensive is the Admin Menu module. It's really useful to access all your Drupal admin items without it being a part of your site's design (theme). But it adds at least a second of load time on EACH page refresh. I try to use a separate user to do minor work on sites I maintain that doesn't have access to the Admin Menu bar but I often have to tweak admin settings...and if you don't know the direct path, I have to log back in as UID=1 or just go to /admin and take it from there.
D) Use Yslow. I've heard of that Firebug extension before at past Drupal User Group meetings but never got around to jumping into it. The rest of this article is what I found with Yslow - I'll leave out the explanation of each Yslow category as they are all explained by clicking on their links and the bulk of my new-found knowledge came from Wim Leers' article. (very well written!)
A failing grade - noone likes to fail. So when I first let Yslow do its performance analysis of my home page, it gave me an F (42 points, higher is better). I knew I had to dig in and find out what I could do to fix this. I wasn't looking forward to maybe finding too much techno-garble that may be over my head (server-settings-wise). I'm a pretty smart guy...but I don't know it all! :)
I didn't know what grade I was looking for but each section in Yslow has a grade so I worked on improving as many as I thought were appropriate.
Core performance settings I was recently adjusting the theme on this site so I had the core-performance enhancements turned off. Be sure to visit /admin/settings/performance and set caching to 'Normal' and turn on "CSS aggregation and compression"
JavaScript - the biggest pig (IMHO). Intial grade B (Put JS at bottom) and F (minimize JS); final grade....both A's!! The moving of the JS to the bottom of my theme's page.tpl.php file was easy (see Wim's article) but it apparently could have some issues (I haven't seen any yet).
The other part was to 'minimize the JS'. Drupal 5 doesn't include compressing your theme's JS files in core (it is in D6) so I found the JS Aggregator module. Installing that as well as following the instructions to add some more code to the bottom of my page.tpl.php file increased my grade overall by 20 points (44 to 64) and from and F to a D!
Add a Futures Expires heading - initial grade F; final grade C. I found this article and used their suggestion to add this line to my .htaccess file - it leaves the more dynamic elements of the theme alone (ads, etc):
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
</FilesMatch>
This increased my grade by another 13 points and I went from a D to a C.
GZip Components - initial grade F; final grade B. I wasn't able to run the ssh command recommended by Wim so I had the line (AddOutputFilterByType DEFLATE text/css application/x-javascript) added in my httpd.conf file by my hosting company.
Use a CDN I left this as an F as using a CDN isn't financially feasible for this project and the site is rather localized so they won't be getting tooooo many visitors from around the world.
To Do:
Configure Etags - initial grade F; final grade F. Since I am running my site from a single server, I had my hoster add "FileETag none" to my httpd.conf file....at first, my score went up to an A, however it is now back down to an F. I'm not sure why and am looking for a solution.
Summary
So that's it! My final score went from a failing F of 42 to a healthy C 79 (one point away from a B where I'd be happy. The biggest boost is to me personally. I feel this has increased the performance of my site substantially and all I did was get three lines of code added to my httpd.conf file (you can't do this on cheap shared hosting), added one module, moved one line of code and added one more php command (2 lines) to my
page.tpl.php file.
All I can do to increase that is use a CDN (not going to happen) and reduce my HTTP requests (and I can't see that happening). Let's hope this resolves things! The main problems with the site were
- slow page loads
- white screens (out of memory)
- out of memory errors
- "SQL Server went away" errors
Since APC was installed, I did have one "SQL Server went away" error but ZERO errors since I did the other optimizations listed above.


