What is WebSocket and how is it different from HTTP?

Updated May 6, 2026

Short answer

WebSocket is a full-duplex communication protocol over a single persistent TCP connection, unlike HTTP which is request-response based.

Deep explanation

WebSockets allow continuous two-way communication between client and server after an initial HTTP handshake. Unlike HTTP, which requires a new request for every response, WebSockets maintain an open connection enabling real-time data exchange with low latency.

Real-world example

Used in chat applications, live sports updates, and stock trading dashboards.

Common mistakes

  • Thinking WebSockets replace HTTP completely instead of complementing it.

Follow-up questions

  • When should you use WebSockets instead of HTTP?
  • Is WebSocket stateless like HTTP?

More WebSockets interview questions

View all →