Real-time collaboration works like magic until two users edit the same line simultaneously. Under the hood, an algorithm must decide whose change wins and get it right every time.
Software engineers faced this problem and two major approaches emerged: Operational Transforms (OT) and Conflict-Free Replicated Data Types (CRDTs). The choice determines how your application scales.
OT requires a centralized system to have total ordering of operations to transform correctly. The core issue is when two servers receiving the same operations in different orders, produce different results. In addition, the number of transformation combinations grow exponentially as users grow, making edge cases and divergence common.
On the other hand, CRDTs are a decentralized data structure which was design to eliminate the need for a central coordinator. CRDTs achieve strong eventual consistency with its metadata, a unique identifier, relative position from peers and a timestamp.
Strong eventual consistency is achieved mathematically:









