Data synchronisation between app and backend

Pavol Travnik
2 min readApr 27, 2023
  1. Polling: Periodically send requests from the frontend to the backend to check for updates. This can be achieved using setTimeout or setInterval functions in JavaScript. While simple to implement, polling can be inefficient and may lead to increased server load.
  2. Long Polling: Similar to polling, but the server holds the request open until new data is available or a timeout is reached. This can reduce the frequency of requests and improve data synchronization, but it may still cause higher server load.
  3. WebSockets: A bidirectional communication protocol that enables real-time data exchange between the frontend and backend. WebSockets are efficient and can handle high volumes of messages with low latency. To use WebSockets in a React app, you can use libraries like Socket.IO or the native WebSocket API.
  4. Server-Sent Events (SSE): A one-way communication protocol where the server pushes updates to the frontend. SSE is suitable for scenarios where the server needs to update the frontend in real-time, and the frontend doesn’t need to send data to the server. To implement SSE, you can use the EventSource API in the browser.
  5. GraphQL Subscriptions: If you’re using GraphQL for data querying and manipulation, you can leverage GraphQL subscriptions for real-time data synchronization. This approach allows you to subscribe to specific data updates and receive them when the backend data changes.
  6. Message Queues and Pub/Sub: These architectures can be used to synchronize data between different components in your system, including frontend and backend. Services like Redis, RabbitMQ, or cloud-based solutions like Google Cloud Pub/Sub and Amazon SNS can be used to implement such systems.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Pavol Travnik
Pavol Travnik

No responses yet

Write a response