How Database Configuration Can Slow Down Drupal

Is your Drupal site slow? Are you losing traffic because of high load times? Your database could be the problem. Read on to find out why your site is lagging, and see how the right server configuration can speed it up.

Drupal needs fast database access

Database lag is the number one factor affecting Drupal's speed. The longer it takes for your database to respond, the slower Drupal goes. And nothing turns visitors away faster than a site that takes forever to load.

How can you avoid slow database performance? One way is to make sure your database is hosted on the same server as your Drupal installation.

A lot of hosting companies keep their databases on separate servers in order to save money on hardware upgrades. Unfortunately, this can really hurt page load times. Why? Because every database query has to travel through the network and back before the data can be processed. The more queries you make, the slower it goes. For database-hungry applications like Drupal, that extra lag time can really add up.

The effects of database lag

Here's a real world example. My previous hosting company used a common two server configuration: Drupal on one machine, MySQL database on the other. Because of the delay between the two servers, Drupal was taking over 3000ms to display my front page. This was unacceptably slow, so I started looking for a new host. That's when I discovered AN Hosting.

AN Hosting avoids database lag by using powerful, multi-core servers that can handle running both Drupal and the database at the same time. Having everything on the same server eliminates the lag, meaning page load times go down significantly.

Drupal Hosting: Page Generation Times

Result: switching to AN Hosting brought the average load time for down to a snappy 130ms. Over 23 times faster! The difference is impressive.

If you'd like to run some tests of your own, take a look at the Devel module. Devel has many useful features, including a report showing all of your SQL queries and how long they take to run.

Impact on Reliability

Single-server configurations have another important advantage over running multiple servers: Reliability. When you have two servers to worry about, that's twice as many things that can go wrong. If either one crashes, your website will stop working until it's fixed. By eliminating one of the servers, you're potentially cutting your downtime in half.

So, if you're still putting up with slow page loads and frequent downtime, ask your hosting provider if they offer a single-server configuration. If not, I strongly recommend checking out AN Hosting. If you want more information, take a look at my full AN Hosting Review.

Posted by John on 2007-03-05