Master Slave Read Write Splitting

Hello,
Any chance this plugin will include read write splitting in the future?
So one could have several slave server queried for reads and writes?

  • jozwikjp
    • The Incredible Code Injector

    Yes looks like it handles this already.. :slight_smile:

    I am not exactly clear on how this should look.

    // add data centers
    add_dc_ip('writedc.msi.net.', 'dc1');
    add_dc_ip('readdc.msi.net.', 'dc2');
    // Database servers grouped by dataset.
    // R can be 0 (no reads) or a positive integer indicating the order
    // in which to attempt communication (all locals, then all remotes)
    //
    // Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS)

    add_db_server('00', 'dc1', 1, 1,'writedc.msi.net','writedc.msi.net'', 'msinet_00', 'msinet', 'dbpassowrd');
    add_db_server('00', 'dc2', 1, 0,'readdc.msi.net','writedc.msi.net'', 'msinet_00', 'msinet', 'dbpassowrd');

    for the DS value I am assuming is the database ID or blog ID, so they would be the same, correct?

    Does this have built in failover? Like if it can't read can it or connect to dc2 it would goto 1?

  • Barry
    • DEV MAN’s Mascot

    for the DS value I am assuming is the database ID or blog ID, so they would be the same, correct?

    The ds value is the postfix of the database - so if I had a db prefix of mydbs_ and am running a 16 db setup, with two reads and a write db I would have something like:

    add_db_server('1', 'dc1', 1, 0,'writedc.msi.net','writedc.msi.net'', 'msinet_00', 'msinet', 'dbpassowrd');
    add_db_server('1', 'dc2', 4, 0,'writedc.msi.net','writedc.msi.net'', 'msinet_00', 'msinet', 'dbpassowrd');
    add_db_server('1', 'dc3', 1, 1,'writedc.msi.net','writedc.msi.net'', 'msinet_00', 'msinet', 'dbpassowrd');

    Does this have built in failover? Like if it can't read can it or connect to dc2 it would goto 1?

    The plugin sorts the databases based on the priority you set in the read and write settings (with a weighting for the local datacenter) and then tries to connect to them in order - when it finds one it can connect to and query, it keeps a track of this connection and will continue to use it for the period of the page processing.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.