Cassandra
MongoDB
master-less
master-slave
database architecture

Master-less model in Cassandra vs master-slave model in MongoDB?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Cassandra and MongoDB solve distributed data problems with different coordination models. Cassandra uses a peer-oriented architecture where any node can coordinate reads and writes, while MongoDB replica sets use a primary node for writes with failover to a new primary when elections happen. The old phrase “master-slave” is largely replaced by “primary-secondary,” but the architectural contrast is still real.

Cassandra Uses a Peer Model

In Cassandra, there is no single write leader for the whole cluster. Any node can receive a client request and act as the coordinator for that operation.

That coordinator routes the request to the replicas responsible for the partition key. Consistency is then controlled per operation through consistency levels.

cql
CONSISTENCY QUORUM;
INSERT INTO events (id, ts, payload)
VALUES (uuid(), toTimestamp(now()), 'ok');

This model is attractive for systems that want write availability across multiple nodes and regions without funneling every write through one elected leader.

MongoDB Replica Sets Use a Primary for Writes

MongoDB replica sets have one primary node at a time. Writes go to that primary, and secondary nodes replicate from it.

javascript
1db.orders.insertOne(
2  { orderId: 42, status: "created" },
3  { writeConcern: { w: "majority" } }
4)

If the primary fails, the replica set elects a new one. During that election window, writes are temporarily unavailable. Reads may still be served from secondaries if the application uses an appropriate read preference, but those reads can be stale.

Consistency and Availability Tradeoffs Differ

Cassandra exposes tunable consistency on each operation. You can pick lower latency with weaker guarantees or choose a stronger level such as quorum to coordinate reads and writes more tightly.

MongoDB’s write path is simpler conceptually because the primary defines the authoritative write order for the replica set. Write concern and read preference then tune durability and read behavior around that primary-centered model.

The result is that Cassandra is often chosen for availability-oriented, write-heavy, globally distributed workloads, while MongoDB is often chosen for application-friendly document queries where a primary-led write path is acceptable.

Data Modeling Style Is Also Different

The architecture difference is only part of the story. The data model matters too.

Cassandra data modeling is query-first. You usually design tables around known read patterns and partition-key distribution.

cql
1CREATE TABLE user_events_by_day (
2    user_id text,
3    day text,
4    event_time timestamp,
5    event_type text,
6    PRIMARY KEY ((user_id, day), event_time)
7) WITH CLUSTERING ORDER BY (event_time DESC);

MongoDB is document-oriented and usually feels more flexible for evolving application schemas and varied queries.

javascript
db.userEvents.createIndex({ userId: 1, eventTime: -1 })
db.userEvents.find({ userId: "u1" }).sort({ eventTime: -1 }).limit(20)

So the decision is not only peer model versus primary-secondary. It is also wide-column query-first modeling versus document-style application modeling.

Failure Handling Feels Different Operationally

Cassandra can often keep accepting writes through other coordinators as long as the required replica set for the chosen consistency level remains reachable. MongoDB write availability depends on having an elected primary.

That does not mean Cassandra is automatically “better at failure.” It means the failure modes and operational tuning differ. Cassandra operators worry about partition key distribution, repairs, compaction, and tombstones. MongoDB operators worry about elections, replica lag, index memory, and shard key quality when sharding is introduced.

Choose by Workload Shape, Not Terminology

Cassandra is often a strong fit when:

  • write throughput is high,
  • multi-region availability matters,
  • access patterns are known in advance,
  • and tunable consistency is acceptable.

MongoDB is often a strong fit when:

  • document modeling fits the application well,
  • query patterns are broader,
  • developer ergonomics matter,
  • and primary-led writes are operationally acceptable.

The architecture label alone should not decide the database. The workload and operational team should.

Common Pitfalls

  • Comparing the systems only by old terminology such as master-less versus master-slave.
  • Applying relational or ad hoc query expectations directly to Cassandra.
  • Assuming MongoDB secondary reads are always fresh.
  • Choosing Cassandra for “scale” without validating the actual access pattern.
  • Ignoring operational complexity when comparing database models.

Summary

  • Cassandra uses a peer model where any node can coordinate writes and reads.
  • MongoDB replica sets use a primary-secondary model with one active write leader at a time.
  • Cassandra offers tunable consistency per operation, while MongoDB centers consistency around the primary write path.
  • Data modeling is query-first in Cassandra and document-oriented in MongoDB.
  • The right choice depends on workload shape, consistency needs, and operational capability, not labels alone.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.