Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Collaborative Editing and Scaling Web Based Editor
Search
Abhishek Gahlot
October 03, 2017
Technology
12
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Collaborative Editing and Scaling Web Based Editor
Tech talk on how to create collaborative editors and scale them to millions of users.
Abhishek Gahlot
October 03, 2017
More Decks by Abhishek Gahlot
See All by Abhishek Gahlot
Code Completion with Scale
abhishekgahlot
0
16
Other Decks in Technology
See All in Technology
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
250
パッチ更新でterraform initが落ちた日
grimoh
1
140
エンタメ企業のM&Aを支えるデータ基盤 ― 統合から店舗のリアルタイム分析まで / Data Engineering Summit 2026
genda
0
170
会社説明資料
persolserverworks
0
9.8k
分析の民主化を支えるメタデータ整備の実践
kakehashi
PRO
4
1.4k
Running Kotlin + Quarkus with Lambda
nealle
1
3.7k
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
340
Classmethod Company Deck
satoshi7
1
680
"優秀な誰か"の下位互換にならないために
yut0naga1_fa
1
1.8k
AI時代のPRレビューにどう向き合うか?
kairim0
1
240
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
340
二歩目のフロントエンド・ウェブアクセシビリティ
camiha
2
570
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Believing is Seeing
oripsolob
1
240
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Building the Perfect Custom Keyboard
takai
2
910
How to make the Groovebox
asonas
2
2.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Building Adaptive Systems
keathley
44
3.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
Git: the NoSQL Database
bkeepers
PRO
433
67k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Site-Speed That Sticks
csswizardry
13
1.6k
Transcript
Collaborative Editing Abhishek Gahlot ( HackerRank )
About Me • Same Guy who spoke in the Morning
• Currently Software Engineer at HackerRank • Worked on Collaborative Editing • Email :
[email protected]
Why Collaboration? • Modern Web Application • Remote and Distributed
Work • Evolution of Web
Collaboration Use Cases • Online Interviews ( HackerRank CodePair )
• Expert Sessions • Document Editing • Feedbacks • Online Learning
Eventual Consistency Convergence • Every edit on different clients should
converge • Balancing servers in order to maintain sticky sessions • Avoid conflicts or divergence
Achieving Convergence • Operational Transformation • Differential Synchronization • CRDT’s
( Conflict-free Replicated Data Type )
Operational Transform Let T be Transform function such that T(x,
y) = (x’, y’) x -> insert(1, ‘a’), delete(3) y -> delete(2) Transform function makes sure document converges
Operational Transform Example
Operational Transform Properties • Easy to apply operation • Difficult
to compute transformation • Too complex and Many corner cases
Differential Synchronization • Diff - O(n*n) • Match • Patch
( Apply operation )
Differential Synchronization Example
Conflict-free Replicated Data Type
CRDT Properties 1 + 2 = 2 + 1 (Commutative)
1 + (2+3) = (1+2) + 3 (Associative) 1 + 1 = 2 ( Not Idempotent )
CRDT Properties A U B = B U A (Commutative)
A U (B U C) = (A U B) U C (Associative) A U A= A ( Idempotent )
CRDT Types • CmRDT ( Not Idempotent ) • CvRDT
( Associative, Commutative, Idempotent )
Building • Frontend Implementation • Backend Implementation • Databases
Frontend Implementation
Web Based Editor • Ace Editor, CodeMirror, Monaco, Draftsjs •
Extracting tokens ( Read, Update, Delete, Insert ) • Applying Tokens
Full Duplex Channel • WebSocket • Sticky sessions • Failure
support • Javascript API
Other Client Side Requirements • Unique Identifier for Editor or
Webpage • Local Storage • Collaborative Algorithm Library
Backend Implementation
Sticky Sessions • Request ending on same server and same
process • Unique document Identifier • Ability to support failure or Node shutdown
Maintain Sticky Sessions • Use HAProxy ( Default websocket support
) • Redirects requests depending on Algorithm used • Algorithms like : IP, Session, URL fragment based
Multiple Servers
Multiple Servers • HAProxy acts a load balancer • Algorithms
by HAProxy helps in Node Failure • High Availability
Multiple Processes Image From : http://insights.mindstix.com/building-a-node-js-infrastructure-that-offers-scalability-fault-resilience-and-zero-downtime/
Multiple Processes • HAProxy redirects to master process of NodeJS
• Customised node module handles id with master process • Master Process redirect websocket connection to child process
Multiple Databases • Sharding • Replication • Connection Pooling from
Application
Maintaining Connections • Make sure upgrade request is done by
server • Use proper unique ID for document for Web Socket
In Production
Architecture
RethinkDB • Realtime Database • Scalable and Distributed • Doesn’t
provide atomic level changes
Memory Issues • Garbage Collection of Node.JS • Huge JSON
and Fast manipulation • Increase Heap Size of Node.JS • Atomic Updates
Network Issues • Flaky Internet • WebSockets Disconnection • High
Latency
Divergence • Read from Database • Reset socket peers •
Update clients
Scrite (In Progress) • http://github.com/scrite • scrite.io •
[email protected]
Questions? Can’t ask here? Ping me at (
[email protected]
)
Thanks!!