Course contentsShow
← System Design
Lesson 1398 of 1,91934. Data Replication StrategiesFree lesson

Consistency Level Per-Operation

Allow clients to specify different consistency levels for individual read and write operations.

Consistency Level Per-Operation

What you'll learn: How allowing different consistency levels per operation gives clients flexibility to balance performance and guarantees based on each request's needs.

The Core Idea

Rather than forcing every read and write to use the same consistency guarantees system-wide, modern distributed databases let clients specify a consistency level for each individual operation. One read might demand strong consistency (always return the latest data), while another tolerates eventual consistency for speed. Similarly, one write might require acknowledgment from all replicas, while another accepts confirmation from just one.

Why This Matters

Not all operations are created equal. Reading a user's profile picture can tolerate slight staleness—if it's a few seconds old, no harm done. But reading a bank account balance before a withdrawal must reflect the absolute latest value. By allowing per-operation consistency levels, you avoid the "one size fits all" trap.

Think of it like shipping options: sometimes you need overnight delivery (strong consistency), sometimes standard ground shipping (eventual consistency) is perfectly fine. Why pay premium prices for everything?

How It Works in Practice

The client includes a consistency parameter with each request:

  • Strong read: "Give me data only after checking all replicas"
  • Eventual read: "Give me whatever's available on the nearest replica"
  • Quorum write: "Confirm once a majority of replicas acknowledge"
  • Local write: "Confirm as soon as one replica accepts it"

Systems like Cassandra, DynamoDB, and Cosmos DB expose this via API parameters. The database routing layer then enforces the requested level, potentially contacting more nodes or waiting longer for stronger guarantees.

Key Takeaway: Per-operation consistency levels let you optimize each request individually—choosing strong guarantees when correctness matters and relaxed guarantees when speed is critical, all within the same application.