MySQL
replication
Tungsten
Galera
database management

MySQL replication Tungsten vs. Galera

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

MySQL replication is a vital component in scaling and ensuring high availability for databases. Two prominent replication technologies that offer high availability and fault tolerance are Tungsten Replicator and Galera Cluster. Both methods have distinct characteristics, strengths, and weaknesses that make them suitable for different scenarios.

Tungsten Replicator

Tungsten Replicator is a powerful tool for MySQL replication developed by Continuent. It provides robust data replication with features that cater to complex database environments. Here are some of its key characteristics:

Key Features

  • Master-Slave Replication: Tungsten supports asynchronous master-slave replication, allowing for flexible replication architectures.
  • Event-Based: Utilizes a complex pipeline of stages to process events through Extractor, Applier, and other processes, resulting in a highly customizable replication.
  • Advanced Filtering: Supports advanced transformation and filtering of data which can be essential for migrating data or selective replication tasks.
  • Cross-Site Replication: Enables replication across different sites and can handle geographically distributed nodes, making it well-suited for global deployments.

Technical Explanation & Examples

Pipeline Approach

Tungsten uses a pipeline-based approach. An event goes through several steps as it moves from the source to the target database. For example, a transaction binlog event is extracted, transformed, and then applied to the target database.

bash
# Simple command to start the replicator on the source
replicator start

Scenario: Filtering Data

If you want to exclude certain tables from being replicated:

yaml
1service:
2  name: sample-service
3filters:
4  exclude-tables:
5    description: "Exclude unwanted tables"
6    script: "tungsten-replicator/lib/filter/abbreviate.js"
7    properties:
8      tables: "audit_logs"

Galera Cluster

Galera Cluster is a synchronous multi-master replication solution for MySQL and MariaDB. It provides high-availability and enhanced write scalability by allowing writes to be performed on any node.

Key Features

  • Synchronous Replication: Ensures that transactions are committed on all nodes, guaranteeing consistency across the cluster.
  • True Multi-Master: Any node can accept read and write transactions, offering maximum flexibility and eliminating the single point of failure.
  • Automatic Node Provisioning: New nodes can join the cluster and be automatically provisioned with the current state of the database.
  • High Performance: Galera uses an optimistic "certification-based replication" approach, which minimizes the delay of replication.

Technical Explanation & Examples

Write-Set Replication

Galera uses a certification-based approach where transactions are grouped as "write-sets". These write-sets are broadcast to all nodes for replication.

sql
1# Example of multiple nodes writing simultaneously
2BEGIN;
3INSERT INTO orders (id, product) VALUES (1, 'Laptop');
4COMMIT; 

If this transaction commits successfully on one node, it is certified and applied across all nodes.

Node Bootstrap

When initializing a new cluster:

bash
sudo galera_new_cluster

This command boots up the first node of the cluster, and additional nodes can join using standard SST (State Snapshot Transfer) protocols.

Comparison Table

Let's compare the two replication technologies with a summary table:

Feature/AspectTungsten ReplicatorGalera Cluster
Replication TypeAsynchronousSynchronous
ComplexityHigher, due to event-based modelSimpler with built-in consensus mechanisms
Write MethodSingle master (master-slave)Multi-master (any node can write)
Consistency ModelEventually consistentStrong consistency
Conflict HandlingNo automatic conflict handlingAutomatic with certification conflicts
New Node HandlingRequires explicit setup and configurationAutomatic provisioning through SST
Geographic DistributionBest suited for diverse distributionsPerformance degrades over large distances
Strong PointsFlexibility, Filtering, TransformationsConsistency, High Availability

Subtopics for Enhanced Understanding

Use Cases

  1. Tungsten Replicator: Suitable for organizations looking for complex replication environments where filtering and partial replication are required. Its cross-site capabilities make it ideal for globally distributed databases.
  2. Galera Cluster: Best suited for scenarios demanding immediate consistency and high availability, such as online transaction processing systems and real-time applications that require high write throughput and are located within a single geographical area.

Installation and Configuration

Both Tungsten Replicator and Galera Cluster require comprehensive installation steps. Tungsten's configuration might seem intricate due to its pipeline flexibility, while Galera offers a more streamlined configuration suitable for multi-master configurations.

Performance Considerations

Galera's synchronous nature might introduce latency in geographically distributed deployments, whereas Tungsten’s approach can better manage such scenarios but at the expense of immediate consistency.


In conclusion, selecting between Tungsten Replicator and Galera Cluster depends heavily on the specific needs of an organization, including consistency requirements, scale, distribution of nodes, and tolerance to conflicts. Understanding the strengths and limitations of each can guide database administrators in making the most suitable choice for their infrastructure.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.