Yesterday my site that averages 200/2000 authenticated/anon users during peak hours topple over due to some serious MySQL locking. We're run a reasonably complex site relying on CCK, Buddylist, OG, Private Message and lots of Views.

Wherever we turned, we get the same answer "tune your MySQL queries". While there is so only so much tuning one can do, it also becomes problematic when your site is growing and you want to roll out new features.

We've been brainstorming a solution and came up with an architecture that would sounded like it would solve our problems (in theory).

We would use one server to host the main site (www.example.com) with core functionality (forums, events, blogs) + aggregated feeds of a number of other subsites (each dedicated to a single feature). These would all be on a second server where each feature would run in a seperate VPS instance with it's own database and httpd. It would look something like this:

example.com - main server aggregating feeds from:
|----> groups.example.com second server - VPS1
|----> classifieds.qatarliving.com second server - VPS2
|----> newfeature.qatarliving.com second server - VPS3
etc.

Our thinking is that if any of these features grows we can just move the VPS onto a new server. Also, if any of these features spike, we can take them down without affecting other services.

To the user it should be seemless since we will aggregate all the data to the main site through RSS feeds.

One of the key requirements would be the sharing of the user table, sessions, userpoints and profiles across all sites (i.e. all the subsites on server two should use those tables from the DB on server 1). Users should be able to move between sites without having to login again and if they get points for posting on a subsite it should increment the main site.

My questions are:
1. Does this make sense at all? Or is there a much simpler and more obvious way to do this?
2. Is it possible to share those tables on a DB that is on a seperate machine altogether?
3. Any other advice?

Comments

gpk’s picture

My knowledge in this area is a bit sketchy, but as I understand it may not be possible to join 2 tables if they are on different servers (maybe even if they are in different DBs) and this effectively prevents any useful splitting of the DB for scalability.

There *is* some info here about how drupal.org manages these problems but a very quick look round didn't show anything up. Worth having a bit of a search though. I think Dries also posted something about this on his site (these posts dated from the time a year or so ago when d.o. was really slow).

AFAICremember the general approach is to use DB replication - master/slave setups and have the DB servers separate from the web servers and have squid in front of all that. Also use as much caching as possible - e.g. node cache and block cache modules (plus more advanced page caching for anon users that Drupal provides), though I don't think they are used here. Actually I did find the modules list for this site http://drupal.org/node/27367.

Note that D6 got rid of all table locks in core so that might also help a lot once your contrib modules have been ported.

HTH

gpk
----
www.alexoria.co.uk

mohamedn’s picture

I've been reviewing the literature on different DB setups. It seems that master/slave may be the only viable option for now...

It would have been interesting if it were possible to launch different drupal modules on different servers - that way you could easily provision resources...

-
Nice community site with classifieds, groups and other Drupal goodness

gpk’s picture

>It would have been interesting if it were possible to launch different drupal modules on different servers
Indeed, the question in my mind still remains - can you split up a single DB between different servers (how would they join tables ... even if it were possible it could be expensive passing all that data from one server to another). Being a bit of a novice in this area I just don't know the answer!!! :P

Setting up replication is not straightforward - see http://drupal.org/node/262782. Possibly support for replication will be built-in to D7. See http://drupal.org/search/node/replication for references, and http://buytaert.net/search/node/replication for info on how drupal.org does it now.

gpk
----
www.alexoria.co.uk