Explain WebRTC vs WebSocket for Realtime.

WebRTC enables peer-to-peer ultra-low-latency audio, video, and data transfer, while WebSocket provides reliable, ordered, bidirectional client-server messaging.

When to Use

  • WebRTC: video/audio calls, live streaming, multiplayer games, screensharing (<200ms latency).
  • WebSocket: chat apps, collaborative docs, IoT control, stock tickers, notifications, dashboards.

Example

In a video call app, WebSocket handles signaling; WebRTC carries the actual media. In a live stock dashboard, a single WebSocket efficiently streams price updates.

Want to prepare deeper?

Explore:

Why Is It Important

Choosing the right protocol affects latency, scalability, and reliability. WebRTC reduces bandwidth with P2P, while WebSocket simplifies central server control.

Interview Tips

  • Lead with: “Media → WebRTC, messaging → WebSocket.”
  • Mention STUN/TURN, ICE, and signaling flows.
  • Call out trade-offs like TURN server costs vs WebSocket simplicity.

Trade-offs

WebRTC

Pros: sub-150ms latency and P2P cost savings Cons: setup complexity, NAT/firewall issues, and TURN server egress cost.

WebSocket

Pros: simple API, ordered messages, and robust libraries Cons: less optimal for high-volume media.

Pitfalls

  • Confusing signaling with transport.
  • Assuming P2P always works.
  • Overusing WebRTC DataChannel for broadcast.
  • Forgetting reconnection/backpressure handling.
TAGS
System Design Interview
System Design Fundamentals
CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Image
One-Stop Portal For Tech Interviews.
Copyright © 2025 Design Gurus, LLC. All rights reserved.