menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Handling R...
source image

Dev

1M

read

144

img
dot

Image Credit: Dev

Handling Race Conditions in Real-Time Apps 🏃💨

  • Real-time apps can often have hidden quirks - a small timing issue where the users presence was not reflected on the board was due to a classic race condition occurring when multiple users joined at the same time.
  • If someone joined during the window between fetching the initial state from the API and establishing the WebSocket connection, the WebSocket may have missed the user-joined event which meant that the new arrival wouldn't always appear on another user’s board.
  • If the WebSocket connection was established first, this could add unnecessary overhead which would delay the user seeing the board.
  • The Event Cache solution was created by implementing a small “event cache” that tracks any incoming WebSocket messages until the UI is ready to process them by fetching the board's state twice.
  • After the events have been placed in the cache, the system can replay the event cache in the correct order to make sure they are accurately reflected on the board.
  • Although there are other methods to prevent this issue, the Event Cache solution offers a more straightforward system that builds on existing REST endpoints, allowing most real-time logic to be kept in the client.
  • Since implementing the event cache strategy, they've seen a decrease in support tickets, better reliability, and a peace of mind knowing that their application is always in sync.
  • Real-time collaboration is powerful, but it can be full of hidden details that can catch one off guard - the event cache solution is one solution to solve the race condition issue.
  • To ensure that subscribers have the best real-time collaboration experience possible, product evolution and constant testing are recommended.
  • Kollabe is a digital whiteboard tool that can be used for teams to have planning poker and retrospectives with, without the occurrence of the “invisible participant” scenario.

Read Full Article

like

8 Likes

For uninterrupted reading, download the app