Leanpub Header

Skip to main content

Conflict-Free Replicated Data Types

A Practical Guide to Building Distributed Collaborative Systems

Conflict-Free Replicated Data Types
This book is 100% completeLast updated on 2026-10-01

Build collaborative software that keeps working when the network does not. This practical guide takes you from distributed systems fundamentals to working CRDT implementations and production-ready collaboration. Learn how CRDTs work, where they fit and how to handle scaling, security, metadata growth and failure in real systems.

Minimum price

$19.00

$29.00

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
187
Pages
About

About

About the Book

Conflict-free replicated data types (CRDTs) are the mathematical backbone of modern offline-first and collaborative applications. This book gives you everything you need to understand them from first principles and build real production systems. Starting with the distributed-systems foundations you need, it develops the core CRDT concepts rigorously, then takes you through complete, runnable implementations of every major data type. You will progressively build a full distributed collaboration system, then confront the production concerns most books ignore: metadata growth, garbage collection, security, scaling, and failure modes. By the end, you will not only understand why CRDTs work but also when to use them, when not to, and how to make them reliable at scale.

Author

About the Author

Steve Publications

Steve is a technology professional with over 20 years of experience in software development, server infrastructure, cybersecurity, vulnerability research and reverse engineering. He specializes in analyzing complex systems, identifying weaknesses and improving security.

Beyond his professional work, Steve collaborates with researchers and industry experts to create practical technical books covering software development, cybersecurity, cloud computing, DevOps, AI and enterprise technologies. His goal is to help IT professionals, students and enthusiasts develop practical skills through clear explanations, real-world examples and hands-on exercises.

At Steve Publications, we use AI to assist with translation, proofreading and editing but not to replace the research, technical expertise or hands-on experience behind our books. Some authors publish under pseudonyms for privacy or professional reasons.

Every book is written, reviewed and maintained by experienced professionals, supported by a private community of over 420 engineers and researchers. We prioritize technical accuracy, practical value and regularly updated content over mass-produced AI-generated text.

We welcome experienced professionals interested in writing or reviewing books, especially in specialized and emerging technology fields. If you'd like to contribute, contact us with your area of expertise.

We stand behind our work. If a book doesn't meet your expectations, Leanpub offers a 60-day money-back guarantee.

Contents

Table of Contents

A Practical Guide to Building Distributed Collaborative Systems

Introduction

  1. What This Book Is About
  2. Who This Book Is For
  3. How This Book Is Organized
  4. The Codebase
  5. What You Will Be Able To Do

Chapter 1: The Collaboration Problem

  1. The Broken Promise of Centralized Collaboration
  2. Real-World Failure Scenarios
  3. Why Locking Fails at Scale
  4. The Offline-First Imperative
  5. A Preview of What Is Possible

Chapter 2: Foundations of Distributed Replication

  1. Single Source of Truth and Its Limits
  2. Replication Architectures
  3. Consistency Models From Strong to Eventual
  4. The CAP Theorem and Its Implications
  5. Linearizability Versus Sequential Consistency
  6. Partition Tolerance in Real Networks
  7. The Trade-Off Spectrum

Chapter 3: Causality and Logical Time

  1. The Nature of Causality in Distributed Systems
  2. Happens-Before and Partial Ordering
  3. Lamport Timestamps
  4. Vector Clocks
  5. Dot Clocks and Dot Updates
  6. Detecting Causality Violations

Chapter 4: Eventual Consistency and Convergence

  1. What Eventual Consistency Actually Means
  2. Convergence Conditions
  3. Monotonicity and the Path to Agreement
  4. When Eventual Consistency Is Not Enough
  5. Measuring and Testing Convergence
  6. The Split-Brain Problem
  7. Causal Delivery and Reliable Broadcast
  8. Summary of Convergence

Chapter 5: Introducing CRDTs

  1. The CRDT Promise
  2. Formal Definition and Required Properties
  3. Join Semilattices and Monotonicity
  4. Why CRDTs Always Converge
  5. Strong Eventual Consistency
  6. The Trade-Offs of Unconditional Convergence
  7. CRDTs and the CAP Theorem
  8. Summary

Chapter 6: Building Your CRDT Toolkit

  1. Project Setup and Dependencies
  2. Core Types and Interfaces
  3. Replica Identity
  4. Dot Clocks
  5. Serialization and Canonical Encoding
  6. The Replica Model
  7. A Minimal Test Harness

Chapter 7: Registers and Flags

  1. The Write-Wins Register
  2. The Last-Writer-Wins Register
  3. The Write-Wins Register with Timestamps
  4. Multi-Value Registers
  5. Dot Clocks for Register Synchronization
  6. Flags and Presence Bits
  7. Complete Example: Running Multiple Replicas
  8. Summary

Chapter 8: Counters and Numeric CRDTs

  1. The Grow-Only Counter
  2. Positive-Negative Counters
  3. The Replica-Numbered Counter
  4. Bounded and Rolling Counters
  5. Floating-Point and Monetary Counters
  6. Complete Example
  7. Summary

Chapter 9: Sets

  1. The Concurrency Problem for Sets
  2. The Grow-Only Set
  3. The Two-Phase Set
  4. Observed-Remove Sets
  5. Last-Writer-Wins Sets
  6. Union-Only and Intersection-Only Sets
  7. Implementation and Replication
  8. Summary

Chapter 10: Maps and Nested Structures

  1. Map-Specific Concurrency Issues
  2. The LWW-Register Map
  3. The MMRG Map CRDT
  4. Nesting CRDTs Within Maps
  5. Deep Convergence Guarantees
  6. Memory and Tombstone Growth in Maps
  7. Summary

Chapter 11: The Synchronization Protocol

  1. Synchronization Requirements
  2. Full State Transfer
  3. Delta-State Replication
  4. Delta Sync with Dot Clocks
  5. Causal Delivery and Message Ordering
  6. Anti-Entropy and Peer Discovery
  7. Implementation of the Sync Protocol
  8. Summary

Chapter 12: Sequences and Ordered Collections

  1. Why Sequences Are Hard
  2. Positioning in Concurrent Documents
  3. RGA Sequences
  4. Logoot Sequences
  5. Positioning Without Gaps
  6. Implementation and Replication
  7. Summary

Chapter 13: Text Editing CRDTs

  1. The Collaborative Editing Problem
  2. Document State Representation
  3. Concurrent Insertion Resolution
  4. Concurrent Deletion Resolution
  5. Cursor Positions and Selection
  6. Real-Time and Offline Editing
  7. Summary

Chapter 14: Building a Distributed Key-Value Store

  1. Architecture and Design
  2. The Replica Process
  3. Persistence and Recovery
  4. Peer Communication
  5. Testing with Multiple Replicas
  6. Running the System
  7. Summary

Chapter 15: Building a Collaborative Text Editor

  1. Editor Architecture
  2. Client-Side CRDT Integration
  3. WebSocket Synchronization
  4. Offline Editing and Replay
  5. Concurrent Editing Tests
  6. Complete Working Example
  7. Summary

Chapter 16: Metadata Growth, Tombstones, and Garbage Collection

  1. The Tombstone Problem
  2. Why CRDTs Leak Memory
  3. Garbage Collection in CRDTs
  4. Compaction Strategies
  5. Bounded Metadata Designs
  6. Summary

Chapter 17: Production Concerns

  1. Security and Authorization
  2. Malicious and Invalid Operations
  3. Performance Optimization
  4. Observability and Debugging
  5. Schema Evolution and Versioning
  6. Scaling to Many Replicas
  7. Summary

Chapter 18: CRDTs Versus Alternatives

  1. Operational Transformation
  2. Centralized Synchronization
  3. Distributed Locking
  4. Consensus Protocols
  5. Event Sourcing and CQRS
  6. Database Replication Strategies
  7. Decision Framework
  8. Summary

Chapter 19: Real-World CRDT Systems

  1. Riak Distributed Database
  2. Yjs Collaborative Framework
  3. Automerge Offline-First Library
  4. Figma and Real-Time Design Tools
  5. Emerging CRDT Databases
  6. Lessons from Production
  7. Summary

Chapter 20: Conclusion and Where to Go

  1. The CRDT Design Philosophy
  2. Where CRDTs Are Going
  3. Open Problems and Research Frontiers
  4. A Final Architecture Checklist
  5. Final Thoughts
  6. Bibliography and Further Reading

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub