Distributed Database Systems Part 1 — What’s in your toolkit ?
By: Sandeep Jagtap
Tags: Distributed Systems, Cassandra, Couchbase, Mongodb, Riak

In Distributed System, set of Processes act together to give an illution of single Process. If we had just a single process, we may run of out of cpu, disk, memory, etc and will be unable to do the things which we want to do. These multiple processes form a Cluster.

This article briefly talks about Distributed System from perspective of following points.

Time

Processes have their own clocks and it is really hard to synchronise them to be on same Time. Time.now() will return different answer for given moment on different processes.

Consensus between processes. Cluster membership.

Processes should know about each other so that they can divide work and data.

Partitioning of data/work between processes

How is Data or work divided between processes.

Replication of data between processes

How is data replicated across processes.

Failover process(es) dying

What happens when a process dies. How is data/work transferred to other process.

New processes joining set of existing processes

What happens when new process joins a cluster of existing processes.

Choice of Data Models

Supported data models for Application developers.

Lets look about Distributed NonRelational Databases

1. Cassandra

Time:

Cassandra does not use vector clocks (logical clocks). It uses timestamps and relies on Clock synchronization across nodes. In case of concurrent updates to same record, the one with higher timestamp wins.

Consensus between processes. Cluster membership:

Masterless Architecture. Client can connect to any Node in cluster. Cassandra uses Gossip protocol. Nodes communicate with few other nodes within cluster using Gossip protocol. Cassandra uses consistent hashing so that there is lesser movement of Data across nodes. Cassandra uses Vnodes one Node owns different ranges of data across Ring.

Partitioning of data/work between processes:

Cassandra uses Ring which is data-structure shared on Node. Ring is made of VirtualNodes which define range of Data each Vnode owns.

Replication of data between processes:

Cassandra stores replicated data on multiple nodes.

Failover process(es) dying:

When process or node dies, the ownership data is transferred to other Vnodes.

Choice of Data Models:

Partition Key — Used to partition data.

Partitioned wide column storage model

2. MongoDB version 4+

Time:

Uses global logical clock, the global logical time applies to entire sharded cluster.

Consensus between processes. Cluster membership:

Master slave architecture. Re-election in case master fails.

Partitioning of data/work between processes:

Non partioned by default. Writes are handled by Master and replicated to slaves.

Replication of data between processes:

Secondaries replicate the primary’s oplog and apply the operations to their data sets asynchronously.

Choice of Data Models:

Json like Document

3. Riak

Time:

Uses dotted version vectors

Consensus between processes. Cluster membership :

Masterless Architecture. Uses gossip protocol

Partitioning of data/work between processes:

Riak uses Ring which is data-structure shared on Node. Ring is made of VirtualNodes which define range of Data each Vnode owns.

Replication of data between processes:

Riak stores replicated data on multiple nodes.

Failover process(es) dying:

When process or node dies, the ownership data is transferred to other nodes.

New processes joining set of existing processes:

Choice of Data Models:

Riak supports Key value data model.

4. Couchbase

Time:

Network Time Protocol (NTP) is used to synchronize time across multiple servers.

Consensus between processes. Cluster membership:

Masterless Architecture. Client can connect to any Node in cluster. Cassandra uses Gossip protocol.

Partitioning of data/work between processes:

In Couchbase, data is always partitioned using the consistent hash value of the document key into buckets, which are stored on the the nodes.

Replication of data between processes:

Choice of Data Models:

Key value data model.

Other interesting Reads