Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Consistent: To Be, or Not To Be

DZone's Guide to

Consistent: To Be, or Not To Be

· Java Zone
Free Resource

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

That's the question.

This is from a client's point of view absent a partition and / or failover.

MongoDB

Is data in MongoDB consistent?

MongoDB executes read and write operations on the primary node, and data is consistent. However, performance is limited because clients do not leverage secondary nodes. The first alternative is to execute read operations on all nodes, primary and secondary. Read performance is better, but data is no longer consistent because replication is asynchronous by default. The second alternative is synchronous replication. The data is consistent, but write performance is worse.

  • Primary
    • Medium Read Performance, Medium Write Performance
    • Consistent Data
  • Primary + Secondary (Asynchronous)
    • High Read Performance, Medium Write Performance
    • Eventually Consistent Data
  • Primary + Secondary (Synchronous)
    • High Read Performance, Low Write Performance
    • Consistent Data

Data may or may not be consistent.

Couchbase Server

Is data in Couchbase Server consistent?

Couchbase Server executes all read and write operations on the primary node, and data is consistent. Performance is high because clients leverage all of the nodes. That's because every node is a primary node.

  • Default
    • High Read Performance, High Write Performance
    • Consistent Data

Data is consistent.

Partitioned versus Replicated

Couchbase Server and MongoDB both implement partitioning and replication. However, the implementations are different.

In MongoDB, a partition is stored within a replica set. A replica set consists of a primary node and multiple secondary nodes. If there were nine nodes, there would be three replica sets with write operations distributed to the three primary nodes. In Couchbase Server, every node is both an active primary node and a passive secondary node. If there were nine nodes, there would be nine primary nodes with write operations distributed to all them (9). This is a high level description of how data is partitioned and replicated within Couchbase Server. A low level description is available in the documentation on vBuckets (link).

If data is replicated, MongoDB would require twenty-seven nodes to distribute write operations to nine nodes.

Discuss

Reddit

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

Published at DZone with permission of Shane Johnson, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}