Friday, December 21, 2012

Galera features beyond just HA

Galera from codership has been getting a lot of attention recently. Galera provides a nice High Availability solution for MySQL where Galera provides synchronous replication with conflict detection using the classic InnoDB Storage Engine. No more playing about with special storage engines of DRBD failover, just continue to use InnoDB and add Galera as the secret sauce for High Availability.

Some of the neat features of Galera are, but are not limited to, multi-master replication, a lightweight implementation of replication and zero failover times due to the multi.master ability. This is not a complete HA solution though, just a component of it, we still need to add some monitoring and failover mechanisms, but as Galera is multi-master this is greatly simplified and can in many cases be handled by the driver or the application with little overhead.

Now, the replication in Galera is synchronous, so that should slow things down a bit, right? Well, yes, but on the other hand Galera can use multiple threads to apply data on the slave, so that should compensate for that somewhat. And how does it compare to MySQL Semi-synchronous replication, which on paper should be that much different?

So I was curious about the multi-threaded apply on the slave that Galera supports? Could this be the multi-thread apply that MySQL has been waiting for all this time? (No, the schema parallel implementation in MySQL 5.6 doesn't count in my mind). So I set out to try this, and this is my thinking:
  • The parallel nature of this should be best exposed when you have many small transaction, so each INSERT is a single row, autocommit transaction.
  • For the sake of the test, remove as much InnoDB overhead as possible and run on Ramdisk (tmpfs)
  • The schema should be simple
  • Simple INSERTs are to be tested, nothing else
  • Multiple INSERT threads.
  • Multi-master operation, but no conflicts.
This is admittedly a simple testcase, but it should tell us something. The schema looks like this:
CREATE TABLE `tab1` (
  `c1` int(11) NOT NULL,
  `c2` char(100) DEFAULT NULL,
  PRIMARY KEY (`c1`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1

And the data to be inserted is
  • column c1 - Unique sequential integer.
  • column c2 - A random string of characters of 5 to 100 characters length.
  • 1.000.000 rows are inserted using 400 threads (200 on each MySQL server).
The hardware I am using for this test is my usual homebrew 8 core AMD box with 16G RAM, nothing exciting but useful.
InnoDB was standard configured here, nothing special, and Galera was using 16 apply threads on the slave, which is probably excessive for this use case. Both MySQL and Galera was using two MySQL servers on the same box.
  • MySQL with semi-synchronous replication ached some 4.830 INSERTs per second.
  • Galera achieved some 12.987 INSERTs per second, nearly 3 times the performance!
This test wasn't something scientific, but then most applications aren't terribly scientific either. To me, it seems like Galera is the Replication system MySQL should have had from the beginning! This rocks! And this also proves to me what I was thinking from the start, that Galera has more to give than a plain HA solution!

/Karlsson

9 comments:

Mark Callaghan said...

I don't think these test results are useful for understanding Galera or semi-sync.

Anders Karlsson said...

Maybe not, but they show something at least, and the use-case isn't completely off I think. But the test is admittedly synthetic. What I wanted to check was if the multi-threaded spply capability of Galera could turn out useful, and it seems it can. This is not no say that there is something distinctly wrong with semi-sync per se, it's here more as having something to compare with.

Once we put stuff on disk, things are different, but I give that a shoot too, as well as running between two separated nodes. One thing the results so far tell me is that it is worthwile to do some more testing.

Mark Callaghan said...

Would much rather read about your experiences deploying it.

Anders Karlsson said...

Mark!

Sure, that will come, so stay tuned. Before getting there I wanted to test some things though. But in a sense you are right, the docs still suffer a bit, so getting started with Galera would be a good suvject for a post also.

/Karlsson

Vinay Joosery said...

Ok, I know that you geeks prefer it the hard way but just in case you want to cheat:
http://www.severalnines.com/galera-configurator/

Shan Jonson said...

There are abounding examples of times back owners of advantageous baby businesses could use banknote to advice body their businesses but can't get the acceptable allotment necessary. These accommodate franchisees who accept beat their accumulation to acquirement their aboriginal authorization and demand to accessible a additional one; merchants whose competitors accept bankrupt and accept the adventitious to buy their competitor's old annual or move into a new location; expansions; buyouts; or artlessly the admiration to move bound on a perceived new opportunity.
Payday Loans

Shan Jonson said...

Before accepting any fund, assertive approval action has to be followed. Regularity of assets becomes all the added capital in this regard. Accommodate capacity of your assets and appliance status. Lenders additionally ask for coffer annual capacity and added such claimed information. The action of accepting ace American beforehand starts with filing out appliance form. Here both offline and online alternatives are available.
auto title loan

Shan Jonson said...

The absolute action of accepting a accommodation is absolutely simple, fast and user-friendly. Alike though, both offline and online options are accessible to get a loan, the online adjustment is awful appropriate to use. It is due to its acceleration as able-bodied as accuracy. It not alone saves time, but additionally provides actual accessibility. Once approved, the aggregation electronically transfers money into your claimed coffer account. As a result, you charge not allow in any backbreaking activity.
https://www.usacheckcashingstore.com/corona

Shan Jonson said...

These loans appear with adorable and adjustable claim alternatives depending on your budgetary position and claimed income. Alike admitting there is a anchored date to pay your dues, no amends or accuse are imposed in the accident of a absent payment. However, it is a acceptable abstraction to accomplish all you payments on the due date itself, back any adjournment may aftereffect in ambagious absorption payments.
www.usacheckcashingstore.com/costa-mesa