How does Raft compare with CRDT for collaborative editing?

185 views Asked by At

I am trying to understand how good Raft can be for collaborative editing when the state is just a JSON blob that can have arrays in it.

My intuition is that Raft is built for safety while CRDT is built for speed (sacrificing availability). Curious to get more opinions on how feasible it is to use Raft for collaborative editing.

1

There are 1 answers

0
Bartosz Sypytkowski On

First of all Raft requires, that all writes must come through the same actor (leader) and exist in the same order before being committed. This means that:

  1. If you don't have access to a current leader from your machine, you won't be able to commit any writes.
  2. In order to secure total order, you need to wait for a commit confirmation from leader, which may require more that 1 roundtrip. For collaborative editing case this means crippling the responsiveness of your application, because you cannot commit the next update (eg. key press) before previous one was confirmed by the remote server.
  3. If your leader will fail, you'll need to wait until the next one is elected before any further updates could be committed.
  4. There's a specific set of conflict resolution problems, that Raft doesn't really know how do deal with. The simplest example: two people typing under the cursor at the same position - you could easily end up with text from both of them being interleaved (eg. at the same position A writes 'hello', B writes 'world', in result you could have text being any permutation of these eg. 'hwelolrldo').

Besides other concerns - like membership and redeliveries - Raft by itself doesn't offer valuable solution for the issues above. You'd need to solve them by yourself.