SlideShare a Scribd company logo
Building Conclave:
a decentralized, real-time
collaborative text editor
Using WebRTC and CRDTs
Presenter: Sun-Li Beatteay
Elise Olivares
Nitin Savant
Sun-Li Beatteay
The Team
Overview
1. Text Editor Basics
2. Primary Challenges and Solutions
3. System Architecture
4. Optimizations
5. Future Plans
What is a text editor?
● List of characters
● Character
○ Value
○ Absolute Index
● Basic operations
○ Insert
○ Delete
HAT
CHAT
insert(“C”, 0)
delete(1)
CAT
H A T
0 1 2
C H A T
0 1 2 3
C A T
0 1 2
Collaborative Text Editor
● Users in different locations editing a
document at the same time
● Document replicated at each user’s location
● Changes applied locally immediately, then
broadcasted to other users
Primary Challenges
● Merging conflicts to create a consistent
document
● Reduce latency to achieve real time
effect
● Scaling the network to house many users
Scenario: Two Users and Central Server
User User
Central
Relay
Server
User1 User2
HAT HAT
CHAT AT
insert(“C”, 0) delete(0)
HAT CAT
User1 User2
HAT HAT
AT AT
delete(0) delete(0)
T T
● Commutativity
○ Insert + Delete = Delete + Insert
○ Operations converge regardless of order
● Idempotency
○ Repeated operations produce same result
● Can’t use absolute indices
Consistency Requirements
● Algorithm heavy
● Modifies operations based on the previous
changes to the document.
● Usually requires a central server and single
source of truth.
Possible Solution: Operational Transformation
Possible Solution: Operational Transformation
User1 User2
HAT HAT
CHAT AT
CAT CAT
delete(1) insert(“C”, 0)
insert(“C”, 0) delete(0)
Commutativity
OT
Possible Solution: Operational Transformation
User1 User2
HAT HAT
AT AT
AT AT
Already
applied
delete(0) delete(0)
Idempotency
Already
applied
OT
Possible Solution: Operational Transformation
Google Wave EtherPadGoogle Docs
Research: Operational Transformation
“Unfortunately, implementing OT sucks. There's a
million algorithms with different tradeoffs, mostly
trapped in academic papers. The algorithms are really
hard and time consuming to implement correctly. […]
Wave took 2 years to write and if we rewrote it today, it
would take almost as long to write a second time.”
- Joseph Gentle
(Google Wave/ShareJS engineer)
Conflict-Free Replicated Data Type (CRDT)
● Created by researchers trying to simplify OT
● Complicated data structure with simpler
algorithms
● Each user has a copy of the CRDT
○ No central server bottleneck
● Each character is treated as a unique object
How to generate globally unique character?
A
Character Object
siteId “3kj7”
value “A”
position [8, 5]
Relative and Unchanging
[ , , ]
Character
Object
siteId “abc4”
value “H”
position [8]
Character
Object
siteId “3kj7”
value “A”
position [8, 5]
Character
Object
siteId “h6f9”
value “T”
position [9]
insert(“A”, 1)
H T
8 9
Characters as Nodes in Tree
H T
A
8
5
9
Characters as Nodes in Tree
H T
A
8
5
9
H T
8 9
A
8.5
Fractional Indices
H T
A
8
5
9
H T
8 9
A
8.5
Fractional Indices
H A T
[8] [8, 5] [9]
Building Conclave: a decentralized, real-time collaborative text editor
C A T
1 2 3
CRDT
User1 User2
delete(“C”, 1)
C A T
1 2 3
C H A T
1 1.5 2 3
A T
2 3
Insert(”H”, 1.5)delete(“C”, 1)
H A T
1.5 2 3
H A T
1.5 2 3
Insert(”H”, 1.5)
Commutativity
H A T
1 2 3
CRDT
User1 User2
delete(”H”, 1) delete(“H”, 1)
Idempotency
H A T
1 2 3
A T
2 3
A T
2 3
A T
2 3
A T
2 3
Primary Challenges
● Merging conflicts to create a consistent
document
● Reduce latency to achieve real time
effect
● Scaling the network to house many users
System Architecture
User User
Central
Relay
Server
UserUser
Limitations of Central Server
● Potentially high latency between users
Peer1
Server
Peer2
10 ms
100-150 ms
Limitations of Central Server
● Potentially high latency between users
● Scaling requires additional resources
and money
Limitations of Central Server
● Potentially high latency between users
● Scaling requires additional resources
and money
● Single point-of-failure
Peer-to-Peer Architecture
Peer 1 Peer 2
Peer 4
Peer 3
Peer 5
Peer 6 Peer 7
WebRTC
● Protocol designed for real-time
communication
STUN STUN
TURN
WebRTC
WebSocket WebSocket
Signaling
Server
WebRTC
● Protocol designed for real-time
communication
● Requires signaling server to initiate
connections between users
● UDP does not guarantee in-order delivery
Peer 1
Peer 2 Peer 3
Peer 1
Peer 2 Peer 3
Insert “A”
Insert “A”
Peer 1
Peer 2 Peer 3
Delete “A”
Insert Op.
Delete Op.
Peer 1
Peer 2 Peer 3
Insert Op.
Delete Op.
What if the delete
arrives first?Peer 1
Peer 2 Peer 3
● Strategy to track operations received from each
user and maintain order
● Each operation includes “version” (siteId, counter)
Version Vector and Deletion Buffer
Peer 1
Peer 2 Peer 3
Peer Op #
1 23
2 5
Version Vector
Insert Op
- SiteId: 1
- Counter: 24
Delete Op
- SiteId: 2
- Counter: 6
Delete Op
- SiteId: 2
- Counter: 6
Peer 1
Peer 2 Peer 3
Peer Op #
1 23
2 5
Version Vector
Insert Char
- SiteId: 1
- Counter: 24
Deletion
Buffer
Delete Op
- SiteId: 2
- Counter: 6
Peer 1
Peer 2 Peer 3
Peer Op #
1 23
2 5
Version Vector
Insert Char
- SiteId: 1
- Counter: 24
Deletion
Buffer
Char
- SiteId: 1
- Counter: 24
Process
Buffer
Delete Op
- SiteId: 2
- Counter: 6
Peer 1
Peer 2 Peer 3
Peer Op #
1 24
2 5
Version Vector
Insert Char
- SiteId: 1
- Counter: 24
Deletion
Buffer
Char
- SiteId: 1
- Counter: 24
Process
Buffer
Delete Op
- SiteId: 2
- Counter: 6
Peer 1
Peer 2 Peer 3
Peer Op #
1 24
2 6
Version Vector
Insert Char
- SiteId: 1
- Counter: 24
Deletion
Buffer
Char
- SiteId: 1
- Counter: 24
Process
Buffer
Version Vector and Deletion Buffer
CONCLAVE
Editor
CRDT Controller Messenger
CONCLAVE
CONCLAVE
CONCLAVE
Version Vector
Optimizations
CRDT Structure and Performance
Initial CRDT (Linear Array)
● Inefficient for big documents
● Slow communication between CRDT and
Editor
{ line: 2, ch: 8} 30
CRDT as a Two-Dimensional Array
Search Insert/Delete Find Index
Linear
Array
O(log N) O(N) O(N)
Two
Dimensional
Array
O(log L + log C) O(C) O(1)
Linear Array vs. Two-Dimensional Arrays
N: # of Characters in Document
L: # of Lines in Document
C: # of Characters in line
Linear array vs. Array of arrays
Total Time (ms)
# of Operations
Linear Array
Two-Dimen Array
WebRTC Connection Management
Peer 1 Peer 2
Peer 3
Peer 2
Peer 3
● Each peer maintains a list of all peers in the network
○ List is updated when peers join/leave the network
● Searches for new peer when a connection closes
Network Array and Peer Discovery
Peer 2
Peer 3
Network
Peer 1
Peer 3
Network
Peer 1
Peer 2
Peer 2
Peer 3
New peer is found!
Network
Peer 3
Network
Peer 2
Can we proactively avoid a single
point of failure?
Peer 2 Peer 1
Peer 3
Peer 4
Load Balancing via Connection Forwarding
Peer 2 Peer 1
Peer 3
Peer 4
Peer 5
Connection
Request
Peer 2 Peer 1
Peer 3
Peer 4
Peer 5
Future Plans
● Improve connection distribution
● Optimize mass insertions and deletions
● Automated tests for P2P network
Feel free to contribute!
● Project Page: https://bit.ly/conclave-site/
● Conclavity: https://bit.ly/conclavity
● Demo: https://bit.ly/conclave-meetup3
My Information
● Name: Sun-Li Beatteay
● E-mail: sjbeatteay@gmail.com
● Website: http://sunli.co
Project Information

More Related Content

PDF
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
PDF
Streaming Data Flow with Apache Flink @ Paris Flink Meetup 2015
PDF
Challenges in knowledge graph visualization
PDF
Time Series With OrientDB - Fosdem 2015
PPTX
Apache Flink: API, runtime, and project roadmap
PDF
Flink Forward Berlin 2017: Matt Zimmer - Custom, Complex Windows at Scale Usi...
PPTX
Continuous Processing with Apache Flink - Strata London 2016
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Streaming Data Flow with Apache Flink @ Paris Flink Meetup 2015
Challenges in knowledge graph visualization
Time Series With OrientDB - Fosdem 2015
Apache Flink: API, runtime, and project roadmap
Flink Forward Berlin 2017: Matt Zimmer - Custom, Complex Windows at Scale Usi...
Continuous Processing with Apache Flink - Strata London 2016

What's hot (20)

PDF
Go at uber
PDF
Francesco Versaci - Flink in genomics - efficient and scalable processing of ...
PDF
Spark Streaming into context
PDF
Apache Flink & Graph Processing
PPTX
When Two Choices Are not Enough: Balancing at Scale in Distributed Stream Pro...
PPTX
Beyond the DSL - Unlocking the power of Kafka Streams with the Processor API
PDF
Flink Streaming Berlin Meetup
PDF
Self-managed and automatically reconfigurable stream processing
PDF
Apache Flink internals
PDF
Flink Forward Berlin 2017: Roberto Bentivoglio, Saverio Veltri - NSDB (Natura...
PPTX
Code Crime Scene pawel klimczyk
PDF
Gelly in Apache Flink Bay Area Meetup
PDF
Ufuc Celebi – Stream & Batch Processing in one System
PDF
Sebastian Schelter – Distributed Machine Learing with the Samsara DSL
PDF
Predictive Datacenter Analytics with Strymon
PDF
Analyzing Blockchain Transactions in Apache Spark with Jiri Kremser
PDF
Pregel: A System For Large Scale Graph Processing
PPTX
Crossing Abstraction Barriers When Debugging In Dynamic Languages
PDF
BKK16-306 ART ii
Go at uber
Francesco Versaci - Flink in genomics - efficient and scalable processing of ...
Spark Streaming into context
Apache Flink & Graph Processing
When Two Choices Are not Enough: Balancing at Scale in Distributed Stream Pro...
Beyond the DSL - Unlocking the power of Kafka Streams with the Processor API
Flink Streaming Berlin Meetup
Self-managed and automatically reconfigurable stream processing
Apache Flink internals
Flink Forward Berlin 2017: Roberto Bentivoglio, Saverio Veltri - NSDB (Natura...
Code Crime Scene pawel klimczyk
Gelly in Apache Flink Bay Area Meetup
Ufuc Celebi – Stream & Batch Processing in one System
Sebastian Schelter – Distributed Machine Learing with the Samsara DSL
Predictive Datacenter Analytics with Strymon
Analyzing Blockchain Transactions in Apache Spark with Jiri Kremser
Pregel: A System For Large Scale Graph Processing
Crossing Abstraction Barriers When Debugging In Dynamic Languages
BKK16-306 ART ii
Ad

Similar to Building Conclave: a decentralized, real-time collaborative text editor (20)

PDF
RedisDay London 2018 - CRDTs and Redis From sequential to concurrent executions
PDF
Real-time Collaborative Editing with CRDTs
PDF
chapter 2 architecture
PDF
RedisConf18 - CRDTs and Redis - From sequential to concurrent executions
PDF
CRDTs and Redis
PPT
An overview of Peer-to-Peer technology new
PPT
IEEE ISM 2008: Kalman Graffi: A Distributed Platform for Multimedia Communities
PDF
Exploring the Possibilities of Sencha and WebRTC
PDF
A Decentralized Application for Secure Private and Group Messaging in a Peer-...
PPTX
video conference (peer to peer)
PPTX
Distributed system sans consensus
PDF
Module: Mutable Content in IPFS
PPTX
High Data Availability and Consistency for Distributed Hash Tables Deployed ...
PPTX
Final peersimp pt
PPT
Peer to Peer services and File systems
PPTX
Decentralised comms Meetup - The dawn
PPTX
Peer Sim & P2P
PPTX
Unit 3 cs6601 Distributed Systems
PDF
P2P File Sharing Web App
PPTX
Practical webRTC - from API to Solution - webRTC Summit 2014 @ NYC
RedisDay London 2018 - CRDTs and Redis From sequential to concurrent executions
Real-time Collaborative Editing with CRDTs
chapter 2 architecture
RedisConf18 - CRDTs and Redis - From sequential to concurrent executions
CRDTs and Redis
An overview of Peer-to-Peer technology new
IEEE ISM 2008: Kalman Graffi: A Distributed Platform for Multimedia Communities
Exploring the Possibilities of Sencha and WebRTC
A Decentralized Application for Secure Private and Group Messaging in a Peer-...
video conference (peer to peer)
Distributed system sans consensus
Module: Mutable Content in IPFS
High Data Availability and Consistency for Distributed Hash Tables Deployed ...
Final peersimp pt
Peer to Peer services and File systems
Decentralised comms Meetup - The dawn
Peer Sim & P2P
Unit 3 cs6601 Distributed Systems
P2P File Sharing Web App
Practical webRTC - from API to Solution - webRTC Summit 2014 @ NYC
Ad

Recently uploaded (20)

PDF
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
PPT
tcp ip networks nd ip layering assotred slides
DOCX
Unit-3 cyber security network security of internet system
PDF
The Internet -By the Numbers, Sri Lanka Edition
PPTX
PptxGenJS_Demo_Chart_20250317130215833.pptx
PPTX
Introduction to Information and Communication Technology
PPTX
international classification of diseases ICD-10 review PPT.pptx
PPTX
Introuction about WHO-FIC in ICD-10.pptx
PDF
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
PPTX
Slides PPTX World Game (s) Eco Economic Epochs.pptx
PPTX
E -tech empowerment technologies PowerPoint
PPTX
Internet___Basics___Styled_ presentation
PPTX
522797556-Unit-2-Temperature-measurement-1-1.pptx
PDF
Sims 4 Historia para lo sims 4 para jugar
PDF
WebRTC in SignalWire - troubleshooting media negotiation
PPTX
presentation_pfe-universite-molay-seltan.pptx
PDF
Tenda Login Guide: Access Your Router in 5 Easy Steps
PDF
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
PDF
Slides PDF The World Game (s) Eco Economic Epochs.pdf
PDF
Cloud-Scale Log Monitoring _ Datadog.pdf
How to Ensure Data Integrity During Shopify Migration_ Best Practices for Sec...
tcp ip networks nd ip layering assotred slides
Unit-3 cyber security network security of internet system
The Internet -By the Numbers, Sri Lanka Edition
PptxGenJS_Demo_Chart_20250317130215833.pptx
Introduction to Information and Communication Technology
international classification of diseases ICD-10 review PPT.pptx
Introuction about WHO-FIC in ICD-10.pptx
FINAL CALL-6th International Conference on Networks & IOT (NeTIOT 2025)
Slides PPTX World Game (s) Eco Economic Epochs.pptx
E -tech empowerment technologies PowerPoint
Internet___Basics___Styled_ presentation
522797556-Unit-2-Temperature-measurement-1-1.pptx
Sims 4 Historia para lo sims 4 para jugar
WebRTC in SignalWire - troubleshooting media negotiation
presentation_pfe-universite-molay-seltan.pptx
Tenda Login Guide: Access Your Router in 5 Easy Steps
APNIC Update, presented at PHNOG 2025 by Shane Hermoso
Slides PDF The World Game (s) Eco Economic Epochs.pdf
Cloud-Scale Log Monitoring _ Datadog.pdf

Building Conclave: a decentralized, real-time collaborative text editor