Tuesday, 3 September 2019

MySQL cluster vs Galera – How to make the right choice

Databases are literally the heart of any application.
As the app becomes popular, the read/write access to databases also increases. Unfortunately, it can become a bottle neck for your application performance too. That’s where database clustering like MySQL clusterGalera, etc. helps.

Why go for Database Clustering?

Let’s now have a look on the need to go for database clustering.
When you have a website with heavy access, the number of requests that actually reach the database will be high. And, speed of the website depends on how fastly the server can get results from the database.
At the same time, the database server has to write data in the tables too. Thus, it has to do simultaneous operations of read/write. That’s where clustering of database server make things work.
In other words, in database clustering, there is a group of servers to handle the work load than a single server. Thus, it can provide data redundancy, load balancing features too. Also, this makes the web application highly available.
However, there is no one size fits all” solution when coming to database clustering. It depends largely on the type of web application, amount of read, write to databases, type of content and many more.
Let’s now have a closer look at the clustering options Galera and MySQL cluster.

MySQL Cluster

Firstly, we’ll check the MySQL cluster option.
MySQL cluster contains the data nodes that store the cluster data and management node that store the cluster’s configuration. Here,  MySQL clients first communicate with the management node and then connect directly to these data nodes.
For synchronization of data in the data nodes, MySQL cluster uses a special data engine called NDB (Network Database). Therefore, in MySQL Cluster there is typically no replication of data. It has only data node synchronization. Again, it uses automatic sharding aka splitting of a large database into small units.
Similarly, MySQL Cluster works in a shared-nothing environment. As a result, no two components of the cluster will share the same hardware. The cluster will be fully operational when at least one node is up on each data node group. As a result, MySQL cluster avoids single point failure and ensures 99.99% availability.
Coming to the real-time scenario, MySQL cluster can provide a response time as low as less than 3 ms.
MySQL clustering in scenarios that need to handle high volume of traffic. Also, it is one of the best methods when you have to scale up read access on the databases.

Galera Cluster

Moving on, let’s have look at the Galera cluster too.
In simple words, Galera Cluster consists of a database server and uses the Galera Replication Plugin to manage replication. It is nothing but a multi-master database cluster that supports synchronous replication. As a result, it provides multiple, up-to-date copies of the data.Thus, it becomes really useful in scenarios where there is a need for instant fail-over.
Galera cluster allows the read and write of data in any node. Again, other typical benefits of Galera cluster include guaranteed write consistency, automatic node provisioning, etc.
Luckily, in Galera cluster, when the network connection between nodes is lost, those who still have access will form a new cluster view. And, those who lost keep trying to re-connect to the primary component. Upon restoring the connection, the separated nodes will sync back and rejoin the cluster automatically. This becomes really useful when you have servers in various geographical locations.
Additionally, it is pretty easy to scale up Galera cluster by adding nodes. Moreover, the process to monitor the cluster status remains simple. Therefore, there is no need to have management node like MySQL cluster.
However, Galera comes with limited MyISAM support. But, it gives best results with the InnoDB storage engine.

Conclusion

In short, database clustering using MySQL cluster or via Galera has its own advantages. And, the real choice depends on the exact usage scenario. 

No comments:

Post a Comment

The complete list of new features in MySQL 8.0

There are over 250 new features in MySQL 8.0. The MySQL Manual is very good, but verbose. This is a list of new features in short bullet f...