[wp-hackers] Plugins and network activations

Peter Westwood peter.westwood at ftwr.co.uk
Wed Jun 29 09:58:08 UTC 2011

On 28 Jun 2011, at 18:05, Mike Schinkel wrote:

> On Jun 28, 2011, at 8:48 AM, Peter Westwood wrote:
>> The correct solution is to not have a table per blog in a Multisite install.
>> Your plugin should either work with the existing table structure or introduce a global table because it needs to do something fundamentally different or not expect to work on any reasonably sized multisite install when network activated without manual work to create the tables.
>> Running through a table creation for every blog on a large multisite install is not scalable and is probably not what you need :)
> I've been thinking about this a lot lately as we're exploring building a SaaS using WordPress as a base.
> I definitely agree that the current process does not scale to have to add tables when a plugin needs tables to all sites.  So you proposed one option to create a shared table that has blog_id as a field so only one table needs to be added. But doesn't that effectively create a hybrid architecture where parts of the data are sharded and parts are not? 
> My understanding is that WordPress uses a sharding approach to enable scalability, yet it is recommending to not use sharding for extensions; isn't that contradictory? If sharding is the appropriate architecture for WordPress' tables why is it not the appropriate architecture for plugin's tables?
> Or is this simple a case of "Yes, it's not a great situation but it's all we got at the moment?"  And if that is the case, maybe it would make sense to come up with a better solution (i.e. a way that it is possible to add new tables to other blogs without timeout?)

Yes and no.

If we for example take the example of a "subscribe to comments" plugin in a multisite install a table per blog is probably wrong for a number of reasons:

1) You can't do anything clever like digesting all emails across all blogs easily
2) You can't provide a single manage my subscriptions UI if the data is sharded across every blog's tables.

In a large install some data needs to be sharded and some needs to be global which is exactly what WordPress itself does - some of the tables in a multisite install are global - users, usermeta, ...

Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
50BF A954 E072 23DB B50A  A319 56C3 8FFF 9C72 AB79

More information about the wp-hackers mailing list