惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
爱范儿
爱范儿
Martin Fowler
Martin Fowler
T
The Blog of Author Tim Ferriss
B
Blog RSS Feed
博客园 - 聂微东
G
GRAHAM CLULEY
Engineering at Meta
Engineering at Meta
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Scott Helme
Scott Helme
AI
AI
S
Security Affairs
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理
AWS News Blog
AWS News Blog
T
Threatpost
Cyberwarzone
Cyberwarzone
www.infosecurity-magazine.com
www.infosecurity-magazine.com
U
Unit 42
V
Vulnerabilities – Threatpost
J
Java Code Geeks
博客园 - Franky
月光博客
月光博客
Blog — PlanetScale
Blog — PlanetScale
NISL@THU
NISL@THU
D
Docker
小众软件
小众软件
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
Y
Y Combinator Blog
A
Arctic Wolf
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
Forbes - Security
Forbes - Security
量子位
PCI Perspectives
PCI Perspectives
美团技术团队
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
I
InfoQ
Security Archives - TechRepublic
Security Archives - TechRepublic
有赞技术团队
有赞技术团队
腾讯CDC
P
Proofpoint News Feed
S
Security @ Cisco Blogs
G
Google Developers Blog
C
Cisco Blogs

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
System Design - 4. Consistency Models
Rajkiran · 2026-05-31 · via DEV Community

Consistency Models Explained: Why Your Bank and Your Twitter Feed Play by Different Rules

The $440 Million Bug
On August 1, 2012, Knight Capital Group — one of the largest market makers on Wall Street — deployed new trading software. Within 45 minutes, their system executed millions of erroneous trades.

The root cause? Inconsistent state across servers. One server had the old software. Seven had the new. The old server kept seeing stale data and acting on it.

By the time humans intervened, Knight Capital had lost $440 million. The company was effectively bankrupt within hours.

This is the most expensive consistency bug in history. And it happened because the engineers hadn't thought clearly enough about one question:

When two parts of a distributed system see different data, which one is right — and what should each one do about it?

That question is the heart of consistency models.

What Is Consistency? (The Intuition)
In a single-server system, consistency is trivial. You write a value, you read it back, you get what you wrote. Simple.

In a distributed system — where data is replicated across multiple servers — consistency becomes a genuine engineering challenge.

Imagine two replicas of a database:

Primary DB: balance = $500 (just received a $200 deposit)

Replica DB: balance = $300 (hasn't received the update yet)

User reads from Replica → sees $300

User is confused: "Where's my $200?"

This is an inconsistency — two parts of the system disagree about reality.

Consistency models define the rules about when and how updates become visible across a distributed system. The spectrum runs from strongest (everyone always agrees) to weakest (everyone eventually agrees).

The Consistency Spectrum
Think of this as a dial. Turn it toward strong — you get perfect agreement but pay in latency and availability. Turn it toward*_ eventual_* — you get speed and availability but accept temporary disagreement.

STRONG ◄─────────────────────────────────────► EVENTUAL

│ │

│ Strong → Causal → Read-your-writes → │

│ Monotonic reads → Eventual (weakest) │

│ │

Slow, expensive, Fast, cheap,

always consistent temporarily inconsistent

Let's walk each level.

1. Strong Consistency (Linearizability)
What it means: After a write completes, every subsequent read — from any server, anywhere — returns that written value.

Write: balance = $500 (at 10:00:01)

Any read after 10:00:01, from any server → returns $500

_The guarantee: _It's as if there's only one copy of the data. All operations appear to happen instantaneously in a global order.

Cost: Every write must be acknowledged by all replicas before returning. This adds latency. If any replica is unreachable, the write blocks.

Who uses it: Banking systems, financial ledgers, inventory management (you can't sell the same seat twice), distributed locks.

Real example: Google Spanner achieves strong consistency globally using synchronized atomic clocks (TrueTime) — a genuine engineering marvel. But it's expensive to operate and has higher latency than eventually consistent systems.

2. Causal Consistency
What it means: Operations that are causally related are seen in the right order by everyone. Unrelated operations can be seen in any order.

The intuition: If you post a comment in response to a post, nobody should ever see your comment without first seeing the post you're responding to.

Alice posts: "Anyone want pizza?" (event A)

Bob replies: "Yes! Where?" (event B, caused by A)

Causal consistency guarantees: no server shows B without first showing A.

Unrelated post by Carol can appear in any order relative to A or B.

Who uses it: Collaborative tools, social feeds where causality matters, distributed version control (Git is causally consistent by design).

3. Read-Your-Writes Consistency
What it means: After you write something, you will always read your own write back. Other users might still see stale data, but you won't.

Why it matters: Imagine posting a tweet and then refreshing your profile — and your tweet isn't there. Infuriating. Read-your-writes prevents this.

How it's implemented: Route all reads for a user to the same replica where they last wrote. Or store the write timestamp in a session cookie and only read from replicas that are at least that current.

Who uses it: Most social applications. When you update your profile photo, you see it immediately — even if others see the old one for a few more seconds.

4. Monotonic Reads Consistency
What it means: If you read a value at time T, you will never read an older value at any time after T.

The problem it prevents: Without this guarantee, a user refreshing their feed could see newer posts, then older posts, then newer ones again — depending on which replica serves each request. The feed appears to go backward in time.

Without monotonic reads:

Refresh 1: sees posts up to 3:00pm ✓

Refresh 2: sees posts up to 2:45pm ✗ (went backwards!)

Refresh 3: sees posts up to 3:05pm ✓

With monotonic reads:

Refresh 1: up to 3:00pm ✓

Refresh 2: up to 3:00pm or later ✓ (never goes back)

Who uses it: Any system where reads come from multiple replicas — databases with read replicas, CDN-cached content.

5. Eventual Consistency (The Weakest)
What it means: If no new writes happen, all replicas will eventually converge to the same value. But in the meantime, different replicas can return different values.

The trade-off: Maximum availability and performance. No coordination required between replicas.

The mental model: Think of DNS. When you change your domain's IP address, it doesn't update everywhere instantly. Some DNS servers have the old IP, some have the new one. But eventually — usually within 24-48 hours — every DNS server in the world agrees. That's eventual consistency.

Who uses it: Social media feeds, shopping cart contents, view/like counts, DNS, CDN caches, any system where brief staleness is acceptable.

Facebook's famous example: When you post something, your friends in different regions might see it at slightly different times. One friend in Mumbai sees it before your friend in São Paulo. Neither is "wrong" — they're just seeing eventually consistent replicas catch up in real time.

Quorum: How You Tune Consistency
Here's one of the most powerful ideas in distributed systems. You can precisely control how consistent your system is by tuning quorum.

_Setup: _Imagine N = 3 replicas (common in Cassandra, DynamoDB).

The magic formula:

W + R > N → Strong Consistency

Where:

N = number of replicas

W = number of replicas that must confirm a write

R = number of replicas that must respond to a read

Walking through configurations:

W=3, R=1 (Write-heavy strong consistency):

Write: must be confirmed by all 3 replicas ← slow writes

Read: only need 1 replica to respond ← fast reads

W + R = 4 > 3 ✓ → Strong consistency

Cost: writes are slow (all 3 must ack)

W=1, R=3 (Read-heavy strong consistency):

Write: confirmed by just 1 replica ← fast writes

Read: must check all 3 replicas ← slow reads

W + R = 4 > 3 ✓ → Strong consistency

Cost: reads are slow (must check all 3)
_
W=2, R=2 (Balanced):_

Write: 2 replicas must confirm

Read: 2 replicas must respond

W + R = 4 > 3 ✓ → Strong consistency

Most common production configuration — balanced trade-off

W=1, R=1 (Eventual consistency):

W + R = 2 ≤ 3 → Eventual consistency

Maximum speed, minimum guarantees

The insight: Quorum lets you tune consistency like a dial. Cassandra, DynamoDB, and Riak all expose these W and R parameters directly. You choose your trade-off per operation — strong for payment confirmation, eventual for updating a "last seen" timestamp.

Vector Clocks: How Systems Track Causality
When multiple nodes write to the same key concurrently, which write wins? This is the distributed systems equivalent of "two people edited the same Google Doc at the same time."

Vector clocks solve this by tracking the causal history of each write.

How it works:

Each node maintains a counter per node it knows about.

Node A writes: {A:1, B:0, C:0} → value="red"

Node B writes: {A:0, B:1, C:0} → value="blue"

Are these concurrent?

A's clock doesn't include B's write. B's clock doesn't include A's write.

→ They're concurrent writes. Conflict detected.

→ System can merge (if data allows) or flag for user resolution.

Node C reads A's write, then writes:

{A:1, B:0, C:1} → value="green"

This is causally AFTER A's write (includes A:1).

→ No conflict with A. C's write wins over A's.

Amazon Dynamo uses vector clocks for shopping cart data. If you add items to your cart on your phone, and separately on your laptop, the system uses vector clocks to detect the concurrent writes and merges the two carts. That's why you sometimes see duplicate items in your Amazon cart — it's the merge surfacing.

When someone asks "should I use strong or eventual consistency?" the right question is: "What is the business cost of showing stale data?"

For a bank balance: showing stale data means someone might overdraft, or fraudulent transactions might go undetected. The cost is catastrophic. Use strong consistency.

For a tweet's like count: showing 1,249 likes instead of 1,250 for 2 seconds? Nobody cares. Use eventual consistency.

Interview Scenario: "Real Failure from Inconsistency"
The Knight Capital story is perfect here. But let's also talk about a subtler, more common failure:

The double-spend problem:

User has $100. Makes two simultaneous purchases of $80 each.

Without strong consistency:

Request 1 → Replica A: reads $100 → approves → deducts → balance $20

Request 2 → Replica B: reads $100 (stale!) → approves → deducts → balance $20

Result: User spent $160 with only $100. System lost $60.

This is why payment systems use strong consistency with distributed locks or ACID transactions. The latency cost is worth it.

The quorum answer to this:

Use W=2, R=2 with N=3.

Both requests must read from 2 replicas.

At least one replica will have seen the first transaction.

One of the reads returns the post-deduction balance → second request blocked.

Key Takeaways
Consistency in distributed systems is a spectrum, not a binary choice.
Strong consistency — everyone always agrees, but it's slow and expensive. Use for financial data.
Eventual consistency — fast and available, but temporarily stale. Use for social feeds, caches, view counts.
Read-your-writes — you always see your own updates. Essential for good UX.
Monotonic reads — time never goes backwards. Essential for readable feeds.
Quorum (W + R > N) — the tuning knob that lets you dial consistency precisely.
Vector clocks — how distributed systems detect and resolve concurrent conflicts.
The business cost of stale data determines which model to use — not engineering preference.