Queue implementation strategy for a collaborative text editor

56 views Asked by At

Recently I have been working on a side project to implement a end to end collaborative text editor using Quill having basic level of conflict resolution using operational transformation, Redis pubsub with websockets and queue for quill delta processing. I am now stuck at how to implement the the queue. the function which will be processing the quill deltas (will be referred as messages further) needs to process it independently for each document concurrently after sorting them based on the timestamp they were created, but the problem I am facing is if i should create a single queue for all the documents (of course it won't be good considering the huge delay it will create for message that are at the very end of the document) but if I will create dynamic no of queues it will be too much. considering a scenario like Google docs, for each actively being edited document, I will have to create same no of queues which will be a bottleneck in my knowledge(of course I can be wrong though).

One more way I was thinking is, what if I keep a single queue and when pulling data from the queue I can find the message belongs to which document and at runtime I can use some sort of hash maps to store messages corresponding to each document to process. But the problem with this approach will come in case of distributed system where there are multiple clients and servers will be involved.

The whole point of this is just to learn the best practices of a design scenario like this and not to implement in a actual project but on a side project to replicate things of a large system in small scale.

Any idea other than this is also welcome considering it should be able to handle some large amount of traffic.

As of now I am completely stuck thinking how to implement it.

0

There are 0 answers