(This Blog post is part of a collaborative work between Me and Youssef El Idrissi, Consult his devTo page for more information: https://dev.to/0xw3ston)
What is Real-Time Communication ?
Real-Time Communication refers to the instant exchange of data between systems, often characterized by low latency, where responses are nearly immediate. This type of communication is critical in applications like messaging, live streaming, gaming, financial trading, and collaborative tools where updates need to be reflected immediately for a seamless user experience.
Some use cases for using RT Comm. Mechanisms:
- Video and Audio Streaming: RTC is essential for low-latency, real-time media streaming in applications like video conferencing, virtual events, and online broadcasting where any delay can disrupt the user experience.
- Live Updates and Notifications: RTC is used to push real-time notifications and alerts to users, such as updates in social media feeds, new messages, stock price changes, or sports scores, allowing users to stay up-to-date without needing to reload the page.
- Instant Messaging and Chat: RTC allows for real-time text, audio, or video messaging, which is essential for communication apps and customer support platforms. Users can see messages immediately without refreshing the app.
What ways/methods exist to achieve that ?
There are 4 common ways to implement live data updates:
- Short Polling: It involves sending HTTP GET Requests every X seconds (most commonly 5 seconds) in order to fetch if there are any updates from the backend server
- Long Polling: This one only sends the backend one single HTTP Request, which the backend tries to delay as much as possible for incase an Update occurs to let the user be notified of it.
- SSE (Server-Sent Events): This method is Unidirectional (from Backend to Frontend), which means the Client cannot send data to the server (not using SSE's anyways).
- WebSockets: this is the best choice in terms of Bidirectional communication (it allows both the client and backend to communicate with eachother), it is the most common way of implementing real time communication.
There are other ways such as WebRTC for video streaming but we won't cover that in this post.
Top comments (0)