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

推荐订阅源

量子位
小众软件
小众软件
S
SegmentFault 最新的问题
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
博客园 - 三生石上(FineUI控件)
C
Check Point Blog
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
罗磊的独立博客
有赞技术团队
有赞技术团队
V
V2EX
Y
Y Combinator Blog
博客园 - 叶小钗
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
F
Fortinet All Blogs
W
WeLiveSecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
S
Security @ Cisco Blogs
TaoSecurity Blog
TaoSecurity Blog
MyScale Blog
MyScale Blog
Hugging Face - Blog
Hugging Face - Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
www.infosecurity-magazine.com
www.infosecurity-magazine.com
PCI Perspectives
PCI Perspectives
H
Heimdal Security Blog
Schneier on Security
Schneier on Security
Security Latest
Security Latest
AWS News Blog
AWS News Blog
月光博客
月光博客
Security Archives - TechRepublic
Security Archives - TechRepublic
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
博客园 - Franky
Cisco Talos Blog
Cisco Talos Blog
T
Threat Research - Cisco Blogs
M
MIT News - Artificial intelligence
T
Troy Hunt's Blog
N
News and Events Feed by Topic
Cloudbric
Cloudbric
Scott Helme
Scott Helme
云风的 BLOG
云风的 BLOG
Attack and Defense Labs
Attack and Defense Labs

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
CRDT vs OT: Choosing the Right Collaboration Algorithm
beefed.ai · 2026-06-18 · via DEV Community
  • Fundamentals: How OT and CRDT actually work
  • Trade-offs: Complexity, performance, storage, and latency
  • Use cases: Which algorithm fits which problem
  • Implementation considerations and popular libraries
  • Migration paths and hybrid approaches
  • Practical Application

The choice between CRDT and OT defines your editor’s user experience as much as your infrastructure: offline behavior, amount of metadata, and the engineering surface area for correctness and performance are all direct consequences of that decision. Make the wrong call and you spend months on transformation edge-cases or years fighting metadata growth and garbage collection.

The problem you're trying to solve is deceptively simple on the surface: multiple people editing a document. The symptoms in the codebase are familiar — wrong ordering on reconnect, invisible edits that later undo other people's work, unbounded memory growth, or an architecture that forces every write through a central sequencer. Those symptoms point at a mismatch between the collaboration algorithm you chose and the real constraints (offline needs, scale, schema complexity) of your product.

Fundamentals: How OT and CRDT actually work

  • Operational Transformation (OT) is a transform-first approach: every user action is expressed as an operation (insert, delete, style-change). When operations arrive out of order they are transformed against concurrent operations so that applying the transformed operation yields the same result on every replica. OT implementations typically rely on a server to sequence operations or on a transformation control algorithm that enforces convergence properties. (interaction-design.org) (ot.js.org)

  • Conflict-free Replicated Data Types (CRDTs) encode merge logic in the data structure itself. Operations (or states) commute: replicas can apply updates in any order and still converge to the same final state, as long as all updates are delivered. CRDTs come in state-based and operation-based flavors; sequence CRDTs (RGA, Treedoc, etc.) and JSON/Map CRDTs are the primitives you’ll see in editors and local-first apps. (pages.lip6.fr)

Practical examples (JavaScript):

Yjs (CRDT) — create a shared text and insert locally, immediately reflected in the local state and later merged in the background:

import * as Y from 'yjs'
const ydoc = new Y.Doc()
const ytext = ydoc.getText('doc')
ytext.insert(0, 'Hello — local, instant, and later reconciled')
const update = Y.encodeStateAsUpdate(ydoc) // binary snapshot

Yjs exposes Y.Doc, Y.Text, and efficient binary updates for transport and persistence. (docs.yjs.dev)

ShareDB (OT) — server-backed OT: clients submit atomic ops; the server records and sequences them and transforms incoming ops as needed:

const ShareDB = require('sharedb')
const backend = new ShareDB()
// Server creates document, client submits op:
// doc.submitOp([{retain: 5}, {insert: ' text'}])

ShareDB implements OT types (e.g., json0, rich-text) and stores ops in an oplog for replay and persistence. (share.github.io)

Important: Both families support optimistic local edits and immediate local feedback. The difference is where the conflict-resolution logic lives: the transport/transform layer (OT) or the data type itself (CRDT).

Trade-offs: Complexity, performance, storage, and latency

Here’s a compact comparison you’ll use in architecture decisions.

Aspect CRDT (typical behavior) OT (typical behavior)
Correctness model Strong eventual consistency via commutative merges; local ops always accepted. (pages.lip6.fr) Convergence via explicit transformation rules and sequencing; correctness requires careful transform composition proofs. (interaction-design.org)
Implementation complexity Conceptually simple (commutative ops), but production-quality CRDTs need careful GC, compact binary formats and high-performance encoding to avoid RAM blow-up. (docs.yjs.dev) (josephg.com) Hard to reason about and easy to get wrong at scale — the transform matrix for rich structures grows quickly; however, mature OT stacks exist for text/JSON. (ot.js.org) (share.github.io)
Runtime performance Naive CRDTs can be heavy (per-element IDs, tombstones). Optimized CRDTs (Yjs, diamond-types, tuned RGA implementations) can be extremely fast and maintainable. (josephg.com) (yjs.dev) Typically lower per-op metadata; server transforms are O(k) where k = number of concurrent ops to account for. With a central sequencer you can keep clients thin. (share.github.io)
Storage & persistence Must store identifiers / tombstones or perform compaction; many CRDT systems expose snapshotting and binary formats to control growth. (docs.yjs.dev) Server keeps an op-log (append-only) that can be compacted into snapshots; easier to reason about retention/retention policies because you control the server. (share.github.io)
Offline & P2P Natural fit — CRDTs shine for peer-to-peer and offline-first models because merges are local and commutative. (pages.lip6.fr) Offline requires storing a local op buffer and replay/transform on reconnect; workable but more engineering to preserve intention and avoid divergence. (ot.js.org)
Developer ergonomics Working with Y.Doc, Y.Text, or Automerge maps well to local-first thinking; you reason about state, not transforms, but you must understand GC and compaction. (docs.yjs.dev) (automerge.org) With OT you reason about operations and write transform(opA, opB) rules; mature libraries hide much of the pain for standard types (text, JSON). (share.github.io)

Contrarian, practical insight from production experience: CRDTs are often marketed as the “easier” option because they sidestep transform algebra; in practice, robust CRDT-based systems require low-level systems engineering (compact binary formats, GC, snapshotting, and careful streaming protocols). Real-world benchmarking and engineering work drove Yjs (and similar projects) to highly optimized designs — not because CRDT theory was trivial, but because implementation and performance are hard. (josephg.com) (yjs.dev)

Latency and UX

Both models support instant local updates (optimistic UI). Perceived latency comes down to transport and how you show remote edits (cursor smoothing, incoming-change animation). OT often uses a server to serialize and transform which simplifies some UX decisions; CRDTs often show remote edits as they arrive and rely on convergence guarantees to resolve order differences. (share.github.io) (docs.yjs.dev)

Use cases: Which algorithm fits which problem

Pick with constraints in mind; here are practical rules of thumb that I’ve applied in production.

  • Pick CRDT when:

    • Offline-first behavior is a hard requirement (mobile-first apps, intermittent connectivity). CRDTs merge naturally and don't require immediate server acknowledgement. (pages.lip6.fr)
    • You need peer-to-peer sync or want to avoid a single sequencer in the critical path. (yjs.dev)
    • Your application tolerates some extra storage or you can invest in compaction/GC infrastructure (or use an optimized CRDT like Yjs). (docs.yjs.dev) (josephg.com)
  • Pick OT when:

    • Your product already centralizes edits for business reasons (real-time collaborative docs with server-side policies, fine-grained access control, audit logs) and you prefer controlling order at the server. (share.github.io)
    • You need minimal client metadata and tighter control of storage on the client (thin clients). (share.github.io)
    • You are integrating with mature OT-based stacks (existing ShareDB/Quill/Firepad ecosystem) and want to leverage proven tooling. (share.github.io)
  • Edge cases / hybrid moments:

    • For rich structured editors (nested nodes, schema constraints) you’ll often reach for CRDTs that have editor bindings (e.g., y-prosemirror) or an OT type designed for your editor (e.g., rich-text delta with ShareDB). Yjs provides first-class ProseMirror bindings to keep schemas consistent while providing CRDT benefits. (github.com)

Implementation considerations and popular libraries

Your architecture will need several layers: the collaboration engine (OT or CRDT), the transport (WebSocket / WebRTC / WebTransport), the awareness/presence layer (cursors, user meta), and persistence/compaction. Here are the well-trodden picks and the trade-offs I run through immediately.

  • Yjs (CRDT) — high-performance CRDT, editor bindings for ProseMirror/TipTap/Remirror, binary updates, GC/compaction primitives, many transports/providers. Good for local-first and peer-to-peer topologies. (yjs.dev) (docs.yjs.dev)
  • Automerge (CRDT) — JSON-like CRDT with a focus on ergonomics; historically heavier on memory but has seen architectural improvements and Rust/WASM implementations. Best for apps where JSON-first modeling matters and peer-to-peer is desirable. (automerge.org)
  • ShareDB (OT) — battle-tested Node.js OT backend; integrates with rich-text (Quill Delta) and json0. Good when you control the server and want a straightforward op-log storage model. (share.github.io)
  • ot.js / Firepad — educational and earlier production stacks based on OT; useful if you want a tight OT integration with contenteditable or CodeMirror/ACE. (ot.js.org)
  • Fluid Framework — Microsoft’s approach: not strictly OT/CRDT; it uses a total-order broadcast and DDS primitives optimized for Microsoft 365 scenarios. Good to study as an architectural alternative (hybrid sequencing + rich DDS semantics). (fluidframework.com)

Operational details you must plan for:

  • Undo/Redo semantics: CRDTs provide local-scoped undo managers (Yjs exposes Y.UndoManager), but semantics differ from traditional global undo stacks. OT systems typically implement undo as inverse-ops or custom transform logic. (docs.yjs.dev) (share.github.io)
  • Persistence & compaction: CRDTs need snapshot + compaction strategies; OT needs op-log trimming and snapshotting. Both need a robust plan for versioning and rollbacks. (docs.yjs.dev) (share.github.io)
  • Connectivity & reconnection: Simulate high-latency, partitioned networks in tests. Test reconnect flows: in OT, you must replay/transform pending ops; in CRDT, you must be able to accept binary deltas and reconcile. (ot.js.org) (docs.yjs.dev)
  • Measurements: track memory per-document, ops/sec, size of serialized updates, and GC latency. Benchmarks (open-source CRDT benchmarks and community write-ups) will help set expectations. (josephg.com)

Migration paths and hybrid approaches

Large products rarely rewrite collaboration layers overnight. Here are practical, low-risk paths I’ve used.

  1. Dual-write shadowing (coexistence):

    • Run OT and CRDT for the same user flows in parallel (write both systems in production traffic but only read from the old system). Validate invariants and divergence with automated checks. This is heavy but the safest route for mission-critical docs.
  2. Snapshot + replay migration (server-driven):

    • Export authoritative state (server snapshot or op-log).
    • Construct a fresh CRDT document and applyUpdate/apply historical ops as updates rather than replaying transforms; verify checksums. Yjs exposes binary update functions for this purpose. (docs.yjs.dev)
  3. Incremental roll-forward (feature-flagged):

    • Start routing a subset of new documents to the new engine and monitor. Use read-after-write checksums and telemetry to validate correctness before broader roll-out.
  4. Hybrid architecture (best of both worlds):

    • Use OT for server-authoritative sequencing where strict ordering or server-enforced invariants are required (e.g., transactional edits, permissions), and CRDTs for client-side offline merges or presence data. Microsoft’s Fluid shows an alternative path by using a total-order broadcast service to provide deterministic sequencing while exposing DDS primitives — it’s neither pure OT nor pure CRDT but a pragmatic hybrid. (fluidframework.com)

Practical snippet — export a Yjs binary snapshot and apply on another node:

// Export
const snapshot = Y.encodeStateAsUpdate(ydoc) // binary

// Import on target
const target = new Y.Doc()
Y.applyUpdate(target, snapshot)

This is the core mechanism for snapshot-and-restore or for bootstrapping new replicas. (docs.yjs.dev)

Practical Application

A concise working checklist and protocol to choose and implement a collaboration stack.

  1. Requirements triage (constrained decision):

    • Offline requirement? Write that down and treat it as boolean.
    • Server-authoritative policies or audit trails? If yes, prefer server-aware OT or a hybrid.
    • Editor type? Plain text, rich text, structured JSON — map to available types (rich-text, ProseMirror, JSON CRDT). (share.github.io) (github.com)
  2. Select engine & library:

    • Prioritize libraries that solve your data model and have production bindings: Yjs for ProseMirror/TipTap, ShareDB for Quill/Delta, Automerge for JSON-first local-first apps. (yjs.dev) (share.github.io) (automerge.org)
  3. Design network protocol:

    • Choose between WebSocket for client-server and WebRTC for p2p. Use providers/adapters already supported by your library (Yjs has y-websocket, y-webrtc, etc.). (docs.yjs.dev)
  4. Implement local optimistic update path:

    • Local change -> apply to local Doc/model -> render immediately -> broadcast change in background.
  5. Persistence & GC policy:

    • For CRDT: implement compaction, snapshotting, and policies to purge tombstones or summarize history. For OT: define op-log retention and snapshot frequency. (docs.yjs.dev) (share.github.io)
  6. Awareness & presence:

    • Implement a small, frequently-updated presence channel separate from document updates. Yjs has an Awareness protocol; ShareDB offers presence patterns. (docs.yjs.dev) (share.github.io)
  7. Testing matrix:

    • Concurrency tests (N clients, M concurrent edits).
    • Partition tests: edits during a simulated network split and reconciliation afterwards.
    • Performance tests: large documents, high-frequency edits, paste events, mass undo/redo.
  8. Telemetry & guardrails:

    • Track ops/sec, bytes transferred per sync, time-to-convergence, GC runtime, memory per document.
    • Add circuit breakers for unusually large updates or retention anomalies. (josephg.com)
  9. Rollout strategy:

    • Pilot on low-risk documents, monitor, then expand with feature flags or tenant gating.

Quick protocol example (OT -> CRDT migration runbook):

  1. Instrument checksums for every op/snapshot in the OT server.
  2. For each doc to migrate, snapshot the document and op-log range.
  3. Create a CRDT doc; apply the snapshot and then reapply ops as idempotent updates.
  4. Run diff checks and hold in read-only mode until integrity checks pass.

Sources

A comprehensive study of Convergent and Commutative Replicated Data Types (Shapiro et al., 2011) - Formal definition and taxonomy of CRDTs; basis for state-based vs operation-based CRDT reasoning. (pages.lip6.fr)

Operational Transformation in Real-Time Group Editors (Sun & Ellis, 1998) - Canonical OT paper describing transform-based convergence and early correctness issues. (interaction-design.org)

Yjs — Homepage - Project overview, claims, and ecosystem; useful for understanding Yjs goals and supported bindings. (yjs.dev)

Yjs Documentation - API (Y.Doc, Y.Text), binary update format, editor bindings, GC/compaction notes and persistence strategy. (docs.yjs.dev)

Automerge (official) - Automerge project goals, JSON-like CRDT semantics, and cross-platform bindings. (automerge.org)

ShareDB Documentation (OT) - ShareDB architecture, OT types (json0, rich-text), persistence adapters and pub/sub for horizontal scaling. (share.github.io)

CRDTs go brrr — Joseph Gentle (engineering blog) - Practical benchmarking and engineering lessons comparing Yjs/Automerge performance and memory behavior (real-world perspective). (josephg.com)

y-prosemirror (Yjs binding for ProseMirror) - Implementation and examples showing how Yjs integrates with ProseMirror for rich structured editing. (github.com)

Fluid Framework FAQ (Microsoft) - Describes Fluid’s approach (total order broadcast and DDSes), and clarifies that Fluid is not a pure OT or CRDT implementation. (fluidframework.com)

OT.js — Operational Transformation docs - Practical explanation and historical context for OT, including examples and links to implementations. (ot.js.org)

Apply the checklist, measure early, and let operational constraints — not theory preferences — decide whether OT or CRDT will fit your editor’s product requirements.