This document discusses distributed locking needs for a real-time multiplayer game and proposes a solution called locker. Locker provides distributed locking through a two phase commit protocol across master nodes to ensure strong consistency. It allows dynamic membership and handles failures through quorum-based writes and asynchronous replication. The author implemented locker as a proof of concept and it has been productionized, providing an alternative to solutions like ZooKeeper for some distributed locking use cases.
3. The need
Only one process per user & world
Cannot reconcile game worlds
Strong consistency
Fine-grained distributed coordination
Lookup table when sending game updates
4. Client Client
visit world #123 visit world #123
World #123 World #123
lock ok lock already_locked
Lock
10. Requirements
~10k conditional writes per second
~3M eventually consistent reads per second
~150k reads on local replica
Lock expires if not kept alive
Dynamic cluster membership
25. ¡°good enough¡±
Problem Solution
Consistency, Serialization,
conditional writes ¡°2 Phase Commit¡±
Multiple serializers,
Availability
quorum (CP)
Local replica Replay transaction log
Dynamic cluster Manual con?guration
Anti-entropy Lock keep alive
26. Implementation
Proof of concept in Friday afternoon
Looked promising, spent ~3 weeks
Turned into production quality
Test race conditions
PropEr
330 lines (!)
28. Beware tradeoffs!
Keep consistency, sacri?ce availability during failure
No persistency, assumes enough masters stays up
No group membership, views
Manually con?gure masters, replicas, quorum value
Assumes perfect network during recon?guration
Not based on a described algorithm