The order of messages as they appear at each replica site is important for the conversation to make sense

The order of messages as they appear at each replica site is important for the conversation to make sense

Intention preservation is an obvious goal in a chat app because the point of the chat app is to facilitate a conversation between two people where messages are created in response to other messages.

Alice asks Bob a question and sees that the question is optimistically added to her replica of the chat history. In the meantime, Bob is typing up a response to another question Alice asked a day before. If Alice is on a really slow network, Bob will not see her new question come into his chat history until some time after he sends his reply to her old question. Bob’s intent is for Alice (the remote site) to see the new message as a response to her old question but because of network latency, Bob’s message will be misunderstood by Alice as a response to her new question. Bob’s intention is not preserved.

How do we prevent this misunderstanding? When Alice gets the event announcing that a message has been added to the conversation by Bob, rather than simply adding the message to the end of her chat history replica, she can perform some comparisons based on the message timestamps to insert Bob’s message in the right place in her chat history. This is possible because the real order of the messages is determined by the timestamp, which is created by the sender client at the time of creation (when the message is sent).

Solution Design

There are many optimistic replication and multiplayer functionalities implementations out there in collaborative editing tools such as Google Docs, Notion, Figma, and Peritext.

Studying these reference designs helped us get some general ideas about how to design the architecture for our system but the specific architecture choice depends on the the specific usage patterns for our chat app.

  1. What is the nature of the data that is being collaborated on?
  2. Does it need to be real-time (Synchronous)?
  3. What kind of mutations are supported?

Replica Data Structure

  1. The Google Docs model (pictured left) supports a real-time synchronous collaboration style where every update to the document form a single linear timeline.
  2. Asynchronous collaboration (pictured right) requires a Git-like model where users can create a private copy (branch) of the document and merge their branch into the main branch when they are ready to do so.

Operational Transformation (implemented by Google Docs) and Conflict-free Replicated Data Types (CRDT) are the two most common classes for conflict resolution strategies.

In our offline-first chat app, we need to support real-time synchronous collaboration of a shared chat timeline. But the mutations are only adding (send a message) updating (reacting to a message and updating the read time of a message for read receipt).

The server and all the clients are managing their own copy of a growth-only set. The server propagates changes to the shared state to by transmitting the update operation. The server propagates changes to the shared state to by transmitting the update operation.

Operational transform implemented in Google Docs is overkill for our chat app use case. For a two-player chat app, we don’t need to worry about the case where two people are editing the same message property (e.g., body, reaction, read time) at the same time because that’s not a valid use case. OkCupid’s chat app does not even allow users to update the body of a sent message.

If the chat app supports more than two players, then we need to implement conflict Mene tГ¤nne resolution for reactions and read times on a message. While that’s a future use case we don’t have to address now, it’s worthwhile to make our solution design general enough to support an arbitrary number of multi-players to it can be easily scaled for that future use case (which we identified earlier as a likely future use case).

Trở thành người đầu tiên bình luận cho bài viết này!

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Bài viết liên quan

Bumble Date, Bumble BFF, and you can Bumble Bizz

Bumble Date, Bumble BFF, and you can Bumble Bizz cuatro. Bumble The Bumble app is one of the greatest matchmaking programs you to deploys three…

Play The new Games In the Mr Gamble Local casino

BlogsHow much time Can it Sample Withdraw Of Mr Play Casino On the web?Pyöräytä Netin Kolikkopelejä Mr Play Gambling establishmentBest CasinosCapitalise On the Normal Advertisements…

Finest No deposit Bonus Casinos To own Uk Players Inside the 2024

PostsBanking And you will IncentivesDeposit and have As much as 150 No Betting Spins Their whole collection of 600+ video game is additionally constructed on…

Pay From the Cellular phone Casino Uk

ArticlesPlayerz Local casinoFree Spins, Totally free Dining table Chips, And you may Totally free EnjoyZero Minimum Put Casino British RecommendationsIncluding And you will Deleting Money…

2024’s Finest Internet leprechaun goes egypt poker Internet sites Updated Jan

ArticlesSpeak about The Collection Of Gaming Calculators For each Video gamePut Match up To $step 1,000Frequently asked questions In the On-line casino BettingBest You Gambling…

Müssen Private Webseiten online casino bankeinzug Das Erscheinungsvermerk Sehen?

ContentEntsprechend Man Herausfindet, Via Welchem Cms Eine Blog Erstellt WurdeWie Man Das Estnisches Mädchen Datiert: 5 TippsBedürfnisse Der Nutzer AuffindenHeiße Frauen Können Parece Gering Eingestellt…

Aprestar Bingo Nosso site Gratis Online

ContentJogue Video Bingo GratisDiferenças Sobre O Bingo Afeito Como Arruíi Vídeo BingoProbabilidades Infantilidade Abichar Apontar BingoJogue Jogos Infantilidade ChatBingo 75How Do You Withdraw Money From…

Discover the top hookup sites in australia

Discover the top hookup sites in australiaWhen it comes down to locating a romantic date or hookup in australia, there are plenty of options to…
Tốt nhất hoặc không là gì cả
Đem những giá trị xứng tầm đến với những khách hàng tuyệt vời.

Alo Auto là một nhánh của hệ sinh thái xe sang lướt thuộc Tập đoàn AutoGroup. Được ra đời với sứ mệnh tôn vinh giá trị của những chiếc xe ô tô.

Chúng tôi luôn mong muốn những “xế yêu” của khách hàng được trang bị những nội - ngoại thất, phụ tùng, phụ kiện, chăm sóc và bảo dưỡng tốt nhất.

Alo Auto luôn nỗ lực từng ngày mang đến lợi ích tốt nhất cho khách hàng bằng sự uy tín và sự chuyên nghiệp của cả tập thể tập đoàn AutoGroup...

Xem thêm
Chia sẻ
Bỏ qua