Distributed database CockroachDB

    CockroachDB (Chinese name Cockroach DB, so it can also be called Xiaoqiang DB), is a distributed SQL database built on transaction processing and strong consistency KV storage, supports horizontal expansion, automatic fault tolerance, strong consistency transactions, and provides SQL The interface is used for data processing and is an open source implementation of Google Spanner/F1.
    CockroachDB is suitable for scenarios where applications require accurate, reliable, and completely correct data. It supports automatic replication, uniform distribution, and data recovery based on minimal configuration. It can be used for distributed, replicable online transaction processing (OLTP), and multiple data centers. It is not suitable for the scenario of reading less and writing more, and can be replaced by an in-memory database, nor is it suitable for complex join queries, heavyweight data analysis and online analytical processing (OLAP).

Scalability
    can run on local machines, single-service, and development clusters. To expand in a running cluster, you only need to specify a new node. At the KV layer, CockroachDB starts as a single empty area. When the single threshold (64M) is reached, the data is split into two areas. Each block covers a continuous segment of the entire key-value space. When new data enters, it continues to split. The purpose is to Keep the area size relatively small and consistent. When the cluster spans multiple nodes, the newly split regions are automatically balanced to nodes with more capacity. CockroachDB uses the peer-to-peer gossip protocol to allow nodes to exchange information such as network addresses and storage capacity.

fault tolerance

    CockroachDB supports software and hardware failures from server restarts to data center downtime, and uses strong consistent replication and automatic recovery after failures. It uses Raft consistency algorithm to ensure the availability of data replication and consistency between replicas. A way to define replica locations, different servers in the same rack for server fault tolerance, different servers in different racks in the same data center for power/network fault tolerance, and different services in different data centers for large-scale network or downtime fault tolerance.

strong consistency

    CockroachDB replicates data multiple times to ensure consistency between replicas. Features: As long as the system clock is consistent with NTP, CockroachDB can ensure serializable SQL transactions; server restarts, machine failures, or data center downtime will not stop; during failover Local or WAN replication no stale data reads; use Raft.

    Implementation: Stored data is versioned through MVCC, so reads only limit their scope to the data visible at the beginning of the read transaction; writes try the Raft consensus algorithm, which guarantees that most replicas always agree on whether the update was successfully committed, writes An update must reach a majority of replicas (2/3 by default) to be considered committed.

 Distributed transaction

    CockroachDB's distributed transactions are clustered, whether it's a few servers in a single machine or multiple servers in multiple data centers. Unlike a sharding setup, there is no need to know the exact location of the data; simply communicate with the nodes in the cluster, and CockroachDB seamlessly fetches the transaction to the correct location.

It is even possible to move tables or entire databases between data centers or cloud infrastructure providers when the cluster is under load. Can easily build consistent applications; supports optimistic concurrency with distributed deadlock detection; default isolation level is serialization.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326319353&siteId=291194637