Drupal multi-site: is it worth it?
Mention Drupal's multi-site feature at a presentation or users's group meeting and a flood of questions will follow.
Most go like this:
"I have N sites that do X. Will multi-site let me do Y?" where N is the number of sites, X is some set of community features, and Y is usually some attempt at integration involving a shared database.
I think a better question would be: "Does using multi-site buy me anything, anything at all?". To answer that question we'll need to compare multi-site setup vs single site installs.
installation
Installing multiple single sites
This is more or less identical to the standard Drupal installation process with a couple of extra steps thrown in.
- Create a docroot folder for each site
- Add a virtual host for each site with the correct docroot directive
- Create a database for each site*
- Download and unpack a copy of the drupal tarball to each site's docroot folder
- Run install.php for each site
- download and unpack modules to each site's sites/default/modules directory
* this step is optional if (unlike me) you feel that using table prefixing to stuff multiple drupal sites into a single database is a good idea.
Installing multiple sites via multi-site
- Create a single docroot folder or use apache's default docroot
- create a database for each site (same as above)
- Download and unpack a single copy of drupal core to the docroot
- create a subdirectory in sites/ for each site*
- Run install.php for each site
- Download and install any shared modules to sites/all/modules, install any site-specific modules to that site's sites/site_url/modules folder
*: You can use sites/default for one of your sites.
Shared modules
With a multi-site installation modules can be shared across all sites by adding them to sites/all/modules. With standalone sites you have to either maintain separate copies of modules for each site or use symlinks.
At first glance this appears to favor multi-site since this cuts down on the number of copies of modules you have to download and keep upgraded, however things aren't always as they appear, as we'll see in the next section.
Module & core updates
This is where the things can get ugly fast if you're running a multi-site setup. There is no way to choose which sites get upgraded when you update core or install the newest version of a module in sites/all/modules. All of your sites sharing the upgraded codebase get upgraded at the same time.
This means you need to have the update tested against all of your sites in a dev environment somewhere and confirmed it's not going to break anything for ALL of your sites before performing the upgrade. It also means you need to run upgrade.php for all of your sites whenever an update is added to the codebase.
For two or three sites this may not seem like a big deal but it's impossible to overestimate the importance of being able to upgrade your sites in a controlled fashion.
Shared databases
Drupal's multi-site feature doesn't include any mystical shared database handling features that aren't present in a standalone installation. This means using multi-site isn't going to buy you anything if you're trying to integrate with a non-drupal database or share tables across multiple sites.
Conclusions
While multi-site installations save time during initial site setup. The ability to share modules across sites via sites/all/modules saves a little time downloading and unpacking modules. Also, since virtual hosts aren't required for each site you save a little time tinkering around with apache's conf files.
Beyond these modest time savings multi-site doesn't bring anything further to the table: it offers no new ways to share databases and it potentially opens up a pandora's box scenario when it's time to upgrade part of your codebase.
If you're in a situation where you need to run multiple sites and have no way to add virtual hosts to apache (perhaps you're constrained by your hosting provider) then it may be a necessity. Beyond that it may be best to treat multi-site handling as a clever but unnecessary feature in Drupal core.
- freeman's blog
- Login or register to post comments
