The MU forums have moved to WordPress.org

"Use another db when current db is full" setup for WPMU? (8 posts)

  1. perryv
    Member
    Posted 16 years ago #

    Hi, I'm researching whether the following scenario can be done in WPMU with plugins and/or hacks.

    It's a multiple-database setup with a twist. We have MySQL database servers named db01.myserver.net, db02.myserver.net, and so on. There's going to be only one main WPMU installation, but many blog sub-accounts. Initially, only db01.myserver.net will be used for all these blogs. But as soon as db01.myserver.net's hard drive becomes full, db02.myserver.net will be used next, and all subsequent blog accounts will be stored in db02.myserver.net. Then when db02.myserver.net becomes full, db03.myserver.net will be used next, and so on.

    Can this be done in WPMU using plugins and/or hacks? But I prefer using plugins alone, if possible.

    I wrestled with hacking my WPMU config files, creating symbolic links, and even editing wpmu-settings.php. I tried both Subdomain and Subdirectory modes of installation, but I failed to produce the setup I want (although Subdirectory mode looked promising).

    But I think one of the key ideas here is that all the databases must have a copy of the admin's tables and data. These are the admin's tables:


    wp_blog_versions
    wp_blogs
    wp_registration_log
    wp_signups
    wp_site
    wp_sitecategories
    wp_sitemeta
    wp_usermeta
    wp_users
    wp_1_comments
    wp_1_links
    wp_1_options
    wp_1_postmeta
    wp_1_posts
    wp_1_term_relationships
    wp_1_term_taxonomy
    wp_1_terms

    Some of the tables have a "wp_1_" prefix. The "1" there is is the admin's numeric user ID, the value in the field wp_users.ID. The user with an ID of 75 has tables with the "wp_1_" prefix.

    But if db01.myserver.net can only accommodate up to user #99, then user #100 will be stored in the next available server db02.myserver.net. So when user #100 gets registered, the tables in db02.myserver.net will be:


    wp_blog_versions
    wp_blogs
    wp_registration_log
    wp_signups
    wp_site
    wp_sitecategories
    wp_sitemeta
    wp_usermeta
    wp_users
    wp_100_comments
    wp_100_links
    wp_100_options
    wp_100_postmeta
    wp_100_posts
    wp_100_term_relationships
    wp_100_term_taxonomy
    wp_100_terms

    The tables without numeric prefixes are the admin's tables.

    So is this really possible with WPMU? What action hooks should I override in my plugin? Or should I hack/modify WPMU itself?

  2. lunabyte
    Member
    Posted 16 years ago #

    Have you seen this plugin?

    http://premium.wpmudev.org/project/Multiple-Databases

    Quite the handy gadget to have on a picnic.

    Oh, and a standalone database server can handle a lot more than 100 users. ;)

  3. perryv
    Member
    Posted 16 years ago #

    Yes, of course, a standalone database server can handle a lot more than 100 users, I used 100 only for purposes of illustration. :-)

    I've seen and tried to use that premium wpmudev plugin before, but it has a hard upper limit of 16 databases (I'm searching for an unlimited "add a db as you go" type), I find the configuration a bit complex and it doesn't do the setup I want. The plugin tends to distribute the data equally across multiple databases, instead of filling one database at a time. But I can surely use that plugin in another project. :-)

  4. lunabyte
    Member
    Posted 16 years ago #

    Um, no. It doesn't have a hard upper limit of 16.

    You can run 16, 256, or 4096.

    If you get a little creative with it, you can run any number of true databases. Like 8 in 16 mode, or 128 in 256 mode. It's a very flexible plugin really.

    Also, as a note, if you fill one db at a time, you're going to end up with an uneven load.

    As for setup, it's not hard at all. Well, unless filling out connection information (username, pass, etc) is tough. :)

  5. theapparatus
    Member
    Posted 16 years ago #

    wordpress.com is using 4096 dbs I believe.

  6. Farms
    Member
    Posted 16 years ago #

    As is edublogs.org :D

  7. andrea_r
    Moderator
    Posted 16 years ago #

    While fillng up one db and moving on to the next might make sense in one way, it does (as luna correctly stated above) spread the load better.

    I moved to 16 dbs and it's been really really awesome.

  8. lunabyte
    Member
    Posted 16 years ago #

    It absolutely spreads it better.

    Else you end up with holes all over the place, and the load being unbalanced as you remove blogs and such. In theory, let's say you had 1000 users per db and 1 db per server. (Using 1000 just as an easy number to work with.)

    Let's say for ever 5000 users, 25% of those are deleted (splog, TOS, user choice, whatever). That's 1250 deleted blogs. Now, it won't be evenly spread across the blog id's, so you end up with (using our 1000 per server number above) 1250 open spots spread in a random pattern over 5 different db servers.

    To cut this short, let's put it this way. Scaling has been something that has been well discussed (shall we say beaten to death) over the life of MU.

    That being the case, trust the regular users here when it comes to this. Most of us have already been down one road or another, made the mistakes and recovered, and all so someone else doesn't have to.

    So, when it comes to scaling, the aforementioned plugin is definitely the way to go.

    Of course, 1db != 1 server either.

About this Topic