Sharing / mirroring two drupal sites on one database

soytea - July 1, 2009 - 14:40

I just wanted to make sure that I'm going about this correctly. I currently have to drupal sites up on two different servers for load balancing. I have them both pointing to the same database with the same user and password. I just simply edited the settings.php file so they match. Is this how I should setup mirrored sites for load balancing. Everything seems to be working fine. Adding users and content will show up on both sites.

Should I be using "shared_" prefixes? If so, why when I want everything to be the same on both sites.

Two Drupal instances cannot share the same database tables.

greg.1.anderson - July 1, 2009 - 20:58

Corruption may result if both instances try to update the database at the same time.

If your site is used heavily by anonymous users and lightly by authenticated users, you can get some quick wins by using the boost module, which serves static HTML pages straight from the web server for anonymous users.

If boost does not give you a large enough boost, things get a lot more complicated. Setting up a large-scale multi-server LAMP stack is non-trivial; Google is your friend here, though, as there are a lot of articles on this subject available. I'll start you off with one by Dries Buytaert, Drupal in the cloud.

Good luck,

- Greg

So what you're telling me is

soytea - July 7, 2009 - 18:17

So what you're telling me is that the "correct" way of mirroring / load balancing Drupal sites is to use a replicated database for each instance?

Drupal <-> Database -> Replicated Database <-> Drupal

As opposed to:

Drupal <-> Database <-> Drupal

I just want to get this straight and clear, I can't seem to find anything that's set in stone on how to mirror Drupal instances.

Here is a guy who has set up

greg.1.anderson - July 15, 2009 - 15:45

Here is a guy who has set up a server configuration as you described in your initial post:

http://www.johnandcailin.com/blog/john/scaling-drupal-step-one-dedicated...

I didn't think that Drupal had any support for simultaneous databases, but it looks like it works. I agree with your comment that this isn't set in stone; I'm still a bit nervous that a heavily-edited site might have problems with simultaneous database writes, and would for my part prefer a solution similar to what was described in the first article I quoted (use a cloud service that abstracts the scale-up for you). This is more expensive on the low end, though.

If you do any tests (like using the node access API to create a bunch of nodes from two servers simultaneously), please post your results.

Thank you & good luck.

- Greg

So I was thinking about this

greg.1.anderson - July 16, 2009 - 05:32

So I was thinking about this some more and realized that since Apache is multi-threaded, there isn't going to be much difference between multiple Apache processes on a single webserver talking to one Mysql database on a remote machine (a supported configuration) vs. multiple Apache processes on multiple webservers talking to one Mysql database on a remote machine. Ergo it should work.

Of course, robust testing of your setup is always a good idea, but all the same, I apologize for my previous answer.

- Greg

 
 

Drupal is a registered trademark of Dries Buytaert.