Bird
Raised Fist0
HLDsystem_design~7 mins

Real-time features in HLD - System Design Guide

Choose your learning style9 modes available
Problem Statement
When users expect instant updates, delays in data delivery cause frustration and reduce engagement. Systems that rely on periodic polling waste resources and cannot guarantee timely information, leading to stale or inconsistent views.
Solution
Real-time features push updates immediately from the server to clients using persistent connections like WebSockets or server-sent events. This mechanism allows the server to notify clients instantly when new data or events occur, ensuring users see fresh information without manual refresh or delay.
Architecture
Client 1
(Browser)
Client 2
(Mobile)
(WebSocket)

This diagram shows clients maintaining persistent connections to a real-time server, which pushes updates immediately from the data source to clients.

Trade-offs
✓ Pros
Delivers updates instantly, improving user experience and engagement.
Reduces unnecessary client polling, saving bandwidth and server resources.
Supports interactive features like live chat, notifications, and collaborative editing.
✗ Cons
Requires maintaining persistent connections, increasing server resource usage.
More complex infrastructure and error handling compared to simple request-response.
Scaling real-time connections can be challenging and may require specialized infrastructure.
Use when user experience depends on immediate data updates, such as chat apps, live dashboards, or collaborative tools, especially when user count exceeds thousands with frequent updates.
Avoid for simple applications with infrequent updates or low user concurrency under 1000 users, where polling or periodic refresh is sufficient and simpler.
Real World Examples
Slack
Uses WebSocket connections to deliver instant messages and presence updates to users, enabling real-time collaboration.
Uber
Pushes live location updates of drivers to riders in real-time using persistent connections to provide accurate ETAs.
Twitter
Streams live tweets and notifications to users instantly using real-time push technologies.
Alternatives
Polling
Clients repeatedly request updates at fixed intervals instead of receiving push notifications.
Use when: Choose when updates are infrequent and real-time latency is not critical, or infrastructure cannot support persistent connections.
Long Polling
Clients send a request that the server holds open until new data is available, then responds and the client immediately re-requests.
Use when: Choose when WebSocket support is limited but near real-time updates are needed.
Server-Sent Events (SSE)
Server pushes updates over a single unidirectional HTTP connection to clients.
Use when: Choose when updates flow only from server to client and simpler implementation than WebSockets is preferred.
Summary
Real-time features deliver data instantly to users by pushing updates over persistent connections.
They improve user experience for interactive applications like chat, live dashboards, and notifications.
Choosing the right real-time technology depends on update frequency, client support, and system scale.