Page MenuHomePhabricator

Evaluate CockroachDB as a replacement to mariadb for wikidatawiki
Closed, InvalidPublicFeature

Description

Feature summary (what you would like to be able to do and where):
Evaluate CockroachDB as a replacement. It's open source and distributed.

Use case(s) (list the steps that you performed to discover that problem, and describe the actual underlying problem which you want to solve. Do not describe only a solution):

  • Automatic failover
  • Horizontal scaling
  • Native cluster setup with self healing
  • Scales both read AND write operations
  • Etc.

Benefits (why should this be implemented?):
The whole WMF ecosystem. See parent tasks.

Event Timeline

So9q renamed this task from Evaluate CockroachDB ad a replacement to mariadb for wikidatawiki to Evaluate CockroachDB as a replacement to mariadb for wikidatawiki.EditedSep 24 2024, 8:43 AM
So9q added subscribers: Ladsgroup, Lydia_Pintscher.

Evaluation by chatgpt4o:
Prompt:
Compare mariadb master with multiple replica setup and manual failover setup with CockroachDB
Response:
When comparing MariaDB master with multiple replica setup and manual failover to CockroachDB, several factors come into play, including scalability, fault tolerance, failover mechanisms, ease of management, and consistency. Here's a comparison:

    1. 1. Architecture
  • MariaDB Master-Replica Setup:
    • Master-Slave: MariaDB uses a master-slave replication model, where the master handles all writes, and the replicas (or slaves) serve read requests.
    • Manual Failover: In a failover situation, a replica must be promoted to a master manually or via external tools.
    • Scaling: Scaling writes is difficult since there's a single master node, though reads can scale by adding more replicas.
  • CockroachDB:
    • Distributed, Multi-Master (Leaderless): CockroachDB is a distributed database where every node can handle both reads and writes, with automatic leader election per data shard.
    • Automatic Failover: If a node fails, CockroachDB automatically redirects queries and elects new leaders for the affected ranges.
    • Scaling: Both reads and writes can be scaled horizontally by adding more nodes to the cluster.
    1. 2. Consistency and Availability
  • MariaDB Master-Replica Setup:
    • Eventual Consistency for Reads: Replication from master to replicas is asynchronous by default, meaning there could be a lag between the master and replicas. Reads from replicas may not always reflect the latest writes.
    • Manual Failover: Failover involves promoting a replica to a master, which might introduce downtime and data inconsistency if not managed carefully.
  • CockroachDB:
    • Strong Consistency (with ACID Transactions): CockroachDB provides strong consistency across all nodes using distributed ACID transactions. It uses a consensus algorithm (Raft) to ensure that all nodes agree on the state of the data.
    • Automatic Failover: It handles node failures automatically without manual intervention, ensuring data consistency and minimal downtime.
    1. 3. Scalability
  • MariaDB Master-Replica Setup:
    • Horizontal Read Scaling: You can scale reads horizontally by adding more replicas, but scaling writes is limited to the capacity of the master node.
    • Vertical Write Scaling: To scale writes, the master node can be upgraded vertically, but there are hard limits depending on the hardware.
  • CockroachDB:
    • Horizontal Scaling: CockroachDB is designed for horizontal scaling of both reads and writes. As you add more nodes, it automatically rebalances data across the cluster.
    • Elastic Scaling: Nodes can be added or removed dynamically, allowing for more fluid scaling without downtime.
    1. 4. Fault Tolerance and Recovery
  • MariaDB Master-Replica Setup:
    • Single Point of Failure (Master): The master is a single point of failure. If it goes down, a replica must be promoted manually or using external automation tools, which may result in downtime.
    • Data Loss During Failover: If the master fails before replicating all data, there is a risk of data loss during failover.
  • CockroachDB:
    • No Single Point of Failure: There is no master node; any node can handle read and write requests, and data is replicated across nodes with automatic failover.
    • Automatic Recovery: In the event of a node failure, CockroachDB automatically redistributes the data to healthy nodes, maintaining availability with minimal disruption.
    1. 5. Management and Operations
  • MariaDB Master-Replica Setup:
    • Complex Failover Management: Manual failover can be complex and requires constant monitoring or third-party automation tools (like MHA or Orchestrator).
    • Operational Overhead: Managing replication, performing failovers, and ensuring consistency across replicas requires significant manual intervention and careful planning.
  • CockroachDB:
    • Automatic Failover and Self-healing: CockroachDB has built-in failover and self-healing mechanisms, requiring little to no manual intervention in case of failures.
    • Simpler Operations: Its distributed architecture simplifies operations since adding or removing nodes and balancing loads is mostly automatic.
    1. 6. Use Cases
  • MariaDB Master-Replica Setup:
    • Traditional Workloads: Best suited for workloads with heavy read traffic and a small number of write-intensive transactions.
    • Applications Needing Eventual Consistency: Suitable for applications that can tolerate eventual consistency and where manual intervention for failover is acceptable.
  • CockroachDB:
    • Cloud-native and Distributed Applications: Ideal for applications that require global distribution, low-latency access, and strong consistency across regions.
    • Highly Available Services: Suitable for applications that need high availability, automatic failover, and transactional consistency, such as financial services, global applications, or e-commerce.
    1. 7. Latency and Performance
  • MariaDB Master-Replica Setup:
    • Low Write Latency (Master): Write operations on the master node are generally low-latency since there’s no coordination with replicas.
    • Replication Delay: Replication can introduce delays for read requests on replicas, depending on the replication mode (asynchronous or semi-synchronous).
  • CockroachDB:
    • Higher Latency for Writes (Due to Consensus): Writes may experience slightly higher latency because they involve consensus (Raft) across multiple nodes.
    • Optimized for Global Distribution: CockroachDB can optimize data placement to reduce latency for users across different geographical regions.
    1. Conclusion:
  • MariaDB Master-Replica Setup is a good option for traditional applications where read-heavy workloads dominate and where you can tolerate eventual consistency and manual failover.
  • CockroachDB, on the other hand, is designed for modern, distributed systems where strong consistency, global distribution, automatic failover, and horizontal scaling of both reads and writes are critical. It's better suited for cloud-native, highly available, and fault-tolerant applications.

Choosing between the two depends on your specific needs in terms of consistency, availability, operational complexity, and scalability.

Evaluation by chatgpt4o:

Please stop flooding our issue tracker with LLM-generated garbage. You are not helping. If we want to be lied to by the bullshit machine, we’ll consult “““AI””” ourselves.

Joe subscribed.

Reason: besides the AI blurb, I don't think this is a reasonable task to open if someone isn't going to do the work themselves, or has the resources to do the work.

I also have my opinion on Cockroachdb specifically, but that's besides the point here.

If we ever decide that CDB is a resonsble potential choice to solve a problem we have[1], we might open a task that will be actually acted upon.

[1] I consider the chance of that happening pretty minimal, personally.

As the database architect of WMF I tend to agree with both Joe and Lucas.

Interestingly enough, this particular database has very recently moved to a proprietary license model, so it is not a viable solution to scaling wikidatawiki.