Reading Time: 3 minutes

In my blog today, I will be comparing CockroachDB with the existing databases like MySQL, Oracle, Cassandra, HBase and so on..

Let’s have a look at what makes CockroachDB different from other databases.

Referring the following table we can compare different databases against each other depending on their features.

As we can see, most of the features are present in CockroachDB, but the main concern is what these short terms actually means ?

CockroachDB MySQL PostgreSQL Oracle SQL Server Cassandra HBase MongoDB DynamoDB Spanner Automated Scaling Yes No No No No Yes Yes Yes Yes Yes Automated Failover Yes Optional Optional Optional Optional Yes Yes Yes Yes Yes Automated Repair Yes No No No No Yes Yes Yes Yes Yes Strongly Consistent Replication Yes No No Optional Optional Optional No No Yes Yes Consensus-Based Replication Yes No No No No Optional No No Yes Yes Distributed Transactions Yes No No Yes Yes No No No No* Yes ACID Semantics Yes Yes Yes Yes Yes No Row-only Document-only Row-only* Yes Eventually Consistent Reads No Yes Yes Yes Yes Yes Yes Yes Yes Yes SQL Yes Yes Yes Yes Yes No No No No Read-only Open Source Yes Yes Yes No No Yes Yes Yes No No Commercial Version Optional Optional No Yes Yes Optional Optional Optional Yes Yes Support Full Full Full Full Full Full Full Full Full Full

So let’s begin by discussing each of them briefly :

Automated Scaling : CockroachDB scales horizontally with minimal operator overhead. You can run it on your local computer, a single server, a corporate development cluster, or a private or public cloud.

Adding capacity is as easy as pointing a new node at the running cluster.



As you put data in, the default range eventually reaches a threshold size (64MB by default). After which, the data splits into two ranges, each covering a contiguous segment of the entire key-value space. This process continues indefinitely; as new data flows in, existing ranges continue to split into new ranges, aiming to keep a relatively small and consistent range size. It is however generally provided in NoSQL Databases like Cassandra, HBase, MongoDB, DynamoDB etc., but still the other features are not present in every NoSql Database. Automated Failover : CockroachDB is designed to survive software and hardware failures by using the following approaches : Replication – is done for data availability, also CockroachDB guarantees consistency between replicas using the ‘Raft consensus algorithm’.

You can locate replicas on: Different servers within a rack to tolerate server failures.

Different servers on different racks within a datacenter to tolerate rack power/network failures.

Different servers in different datacenters to tolerate large scale network or power outages. See detailed description : Automated Failover/Replication Automated Repair – is provided to overcome failures like : Short-term failures (such as a server restart) – CockroachDB uses Raft to continue seamlessly as long as a majority of replicas remain available.

Longer-term failures (such as a server/rack going down for an extended period of time or a datacenter outage) – New locations in the cluster are identified and the missing replicas are re-replicated in a distributed fashion using all available nodes and the aggregate disk and network bandwidth of the cluster. Automated Repair : Discussed Above. Strongly Consistent Replication / Consensus-Based Replication : CockroachDB guarantees the the highest defined SQL isolation level i.e, “serializable”.

It achieves – Read consistency using custom time-based synchronization algorithms

Write consistency using Raft consensus algorithm Distributed Transactions : A distributed transaction is a database transaction in which two or more network hosts are involved.

Usually, hosts provide transactional resources, while the transaction manager is responsible for creating and managing a global transaction that encompasses all operations against such resources.

Whether it’s a few servers in a single location or many servers across multiple datacenters, you don’t need to know the precise location of data unlike with sharded setups. While all of the NoSQL databases are distributed databases, only CockroachDB supports distributed transactions and provides strong consistency. ACID Semantics : Every transaction in CockroachDB guarantees ACID semantics (same as for every database except for NoSQL databases) spanning arbitrary tables and rows, even when data is distributed. Eventually Consistent Reads : Optionally allows reading from replicas that do not have the most recently written data.

SQL : At the lowest level, CockroachDB is a distributed, strongly-consistent, transactional key-value store, but the external API is Standard SQL with extensions. Open Source : Allow us to contribute to it by : filing bugs

suggesting improvements

requesting new features, or

by opening an issue.

Happy Reading 🙂

References : https://www.cockroachlabs.com/docs/cockroachdb-in-comparison.html