Course contentsShow
← System Design
Lesson 550 of 1,91915. Consistency ModelsFree lesson

Consistent Prefix

Ensuring that reads never see out-of-order writes, preserving the sequence of operations even if stale.

Consistent Prefix

You'll learn: How to guarantee that writes are always observed in the correct order, even when you're reading stale data.


What Is Consistent Prefix?

Consistent Prefix is a consistency model that ensures you never see operations out of order. If a series of writes happens in sequence (A → B → C), any observer will see them in that exact order — though they might not see all of them yet. You could see [A], or [A, B], or [A, B, C], but never [B] alone, or [A, C] without B, or [C, B, A].

Think of it like reading a book chapter by chapter as it's being written. You might only have chapters 1–3 while chapter 5 exists somewhere, but you'll never accidentally read chapter 3 before chapter 1. The sequence is preserved, even if you're behind.

Why Does This Matter?

In distributed systems with multiple replicas, writes can propagate at different speeds. Without Consistent Prefix, you might read from a replica that received operation #2 but not #1 yet — creating confusion or breaking application logic.

Example: Imagine a conversation where Alice posts "What's for dinner?" and Bob replies "Pizza sounds great!" Without Consistent Prefix, a reader might see Bob's reply first, then Alice's question — completely backwards and nonsensical.

Where It Fits

Consistent Prefix is weaker than causal consistency (which tracks cause-and-effect across all operations) but stronger than basic eventual consistency (which makes no ordering guarantees). It's particularly useful for append-only logs, messaging systems, and feeds where order matters but you can tolerate being slightly behind.

Key Takeaway: Consistent Prefix guarantees that reads preserve write order—you might see stale data, but never scrambled sequences that violate causality within a single chain of operations.