A few days ago I copied a Drupal site up on a GoDaddy server for somebody and noticed something immediately. My freaking sites were running REALLY slow on my server. This shared $10/mo GoDaddy server was outperforming my beefed up dedicated box hosted at a really good company by like 10x. How could this be? I wasn't quite sure, but it made me realize that Drupal sites really could run fast and I needed to find out what I was doing wrong.
Well there were a few things I have discovered during my search these last few days. Below I will share some steps on how to get your Drupal 5 site rocking like Stephen Hawking.
This is where I went wrong. It turns out that adding lots of rewrite cases to your .htaccess has a huge performance hit, like really big. So big, that it's the first thing I'm listing in my list and I think this is probably one of the most overlooked things. Changing my .htaccess 301s and redirects to a PHP server-side redirect improved performance literally 10x. It made all these other changes seem small, although they still help. If you have full control over your box you may also want to consider ditching the .htaccess and moving it into your conf file.
I also installed eAccelerator on my box and noticed about a 20 - 30% increase in PHP render time. I would definitely recommend this as a quick way to get your sites rendering quicker.
External File Server
I store many of my files on an external file server that is built lightweight and for static content delivery. I would highly recommend abstracting most of your theme and site files to an external source. This greatly cuts down http requests and allows your web server to focus on what it does best.
Minimize http requests
MySQL / PHP Configuration
It is important to make sure that your MySQL and PHP have the right variables set and are optimized according to your needs. In most cases you are going to want to allocate a good amount of resources towards MySQL and PHP as Drupal is very database and server-side intensive.
This is a great module for sudden traffic bursts, IE Digg or other social sites that may crush your server or SQL. This module basically redirects visitors (via htaccess) to a static page that has been rendered out. The module is pretty clean and the performance increase is HUGE. If you are looking to get around 50,000 or more anonymous visitors in a short period of time, this is a great way to handle it.
Keep in mind, that while this module saves your SQL and PHP it can slow down page display time as it has various rewrite rules in the htaccess that may not be needed when traffic is lower.
The Devel module for Drupal is a great way to check and see how your code is running. You are able to see the queries running for each page, the page rendering time and a lot of other helpful stuff. This module helped me figure out that my SQL and PHP was working really well so my bottleneck had to be something else. I'm sure in some cases you'd be able to find your SQL or PHP bottlenecking by using this module.
Lots of Modules
It should also be noted that having lots of modules enabled will require more processing time and could slow your site down. Despite the performance cost, I run LOTS of modules on most of my sites and although the render time may be 400ms VS 200ms I don't really see this as a super big issue because you're getting like 10x the site. Under heavy traffic these types of things could creep up on you, but I think the performance cost is worth it because it's making your site better. Right now I'm rocking lots of modules on my sites and my pages are loading very fast. This also depends greatly on how well the modules are codes as well.
Be careful if you're using a lot of XML-RPC requests. It should be noted that each XML-RPC call runs a full Drupal bootstrap which could potentially slow your server down quite a bit if you're doing a lot of these.
These are some good starting points towards speeding up your Drupal site. Hopefully this helps some of you guys out that may be suffering from what I have been suffering from these last few months.
Drupal for president of the United States!
Filed under:Internet / Tech, Drupal, Server, Performance, Optimization