Mysql – Best database replication technique for a very unstable (power wise) network

data synchronizationMySQLreplication

I am part of a small network (500 users) who are all connect via WiMax to each other. The people connected to this network live in about a 70 km radius. This network allows for a transfer speed of about 1.5 MB/s. We are using a website which uses a Mysql database. We are all living in South Africa which is currently experiencing a phenomenon call Load Shedding. This is where the municipalities turn of the power to specific regions to save power as South Africa is currently experiencing a power shortage.

We want to set up a database replication grid for this website in question. In the case of load shedding, no warning is given for power failures so it can be assumed that the servers will shut down abruptly.

Can anyone recommend a database setup and replication type the will allow seamless synchronization after load shedding occurred? We would like for both servers to have write access for in the case that one server goes down, the user will still be able to connect to the online server.

So in a nutshell:
– Seamless/Easy/Automatic synchronization in the case of inconsistencies in the database.
– Fast enough to not delete the entire database, and re-download it form the acting master server.
– Able to keep sync with a limit of 1.5MB/s bandwidth.
– No data is lost. Both servers have to be in perfect sync.

Some other technical details of the database:
– Handles average of 250 queries per minute.
– Database size is 1 GB in size.

I have read up about Master-Master synchronization, but also read that it is not very reliable in abrupt shutdowns, nor for low bandwidth applications. Does anyone have an idea for a setup like this.

Best Answer

If MySQL isn't a hard requirement, consider FoundationDB Key-Value Store + SQL Layer.

FoundationDB is a distributed Key-Value database with ACID guarantees and strong fault-tolerance. You can setup a cluster spread across the different municipalities, and if a server in the cluster goes down, the rest of the cluster continues to operate and accept writes. Changes are automatically synced to the downed node once it comes back online.

Here's a video where you can see this in action: Dave is killing the power to different nodes in the cluster, and demonstrating the cluster remains up and accepts writes. This blog post walks through what happens to the database in the case of a network partition and adds more technical context.

SQL Layer is a process that maps SQL statements to the Key-Value Store. It which presents a full, ANSI-compliant SQL API to your application.

Full disclosure: I'm an engineer at FoundationDB