JavaScript CRDTs的比较

Collaboration is one of the most requested features on uMap. I’ve talked in previous articles how we could add real-time features “the simple way”, by:

合作是上最受欢迎的功能之一。我在之前的文章中讨论了如何通过“简单的方式”添加实时功能。

  • a) catching when changes are done on the interface ;
  • a) 捕捉接口上的更改;
  • b) sending messages to the other parties and ;
  • b)向其他方发送消息;
  • c) applying the changes on the receiving client.
  • c) 在接收客户端上应用更改。

This works well in general, but it doesn’t take care of conflicts handling, especially when a disconnect can happen.

这在一般情况下运行良好,但它没有处理冲突处理,特别是在断开连接时。

For this reason, I got more into “Conflict-free Resolution Data Types” (CRDTs), with the goal of understanding what they are, how they work, what are the different libraries out there, and which one would be a good fit for us, if any.

出于这个原因,我更深入地研究了“无冲突解决数据类型”(CRDTs),目标是了解它们是什么,它们如何工作,有哪些不同的库存在,以及如果有的话,哪一个适合我们。

As things are changing quickly in this field, note that this article was written in March 2024.

由于这个领域的变化迅速,请注意本文是在2024年3月写的。

Part 1 - What are CRDTs?

第1部分 - 什么是CRDTs?

Conflict-free Resolution Data Types are a family of data types able to merge their states with other states without generating conflicts. They handle consistency in distributed systems, making them particularly well-suited for collaborative real-time applications.

无冲突解决数据类型是一类能够与其他状态合并而不产生冲突的数据类型。它们处理分布式系统中的一致性,使它们特别适用于协作实时应用。

CRDTs ensure that multiple participants can make changes without strict coordination, and all replicas converge to the same state upon synchronization, without conflicts.

CRDTs确保多个参与者可以在没有严格协调的情况下进行更改,并且在同步时,所有副本都会收敛到相同的状态,而不会产生冲突。

“Append-only sets” are probably one of the most common type of CRDT: you can add the same element again and again, it will only be present once in the set. It’s our old friend Set, as we can find in many programming languages.

“仅追加集合”可能是最常见的CRDT类型之一:您可以一次又一次地添加相同的元素,但集合中只会存在一次。这就是我们在许多编程语言中都可以找到的老朋友Set

Why using CRDTs?

为什么使用CRDTs?

For uMap, CRDTs offer a solution to several challenges:

对于uMap,CRDT提供了解决几个挑战的方案:

  1. Simultaneous Editing: When multiple users interact with the...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.137.1. UTC+08:00, 2024-11-23 06:37
浙ICP备14020137号-1 $访客地图$