WebSocket
A protocol enabling persistent, bidirectional communication between browser and server.
Definition
WebSocket is a communication protocol providing full-duplex, persistent connections between clients and servers. Unlike HTTP's request-response pattern, WebSockets allow either side to send messages at any time, enabling real-time features.
WebSockets are ideal for applications requiring instant updates: chat, live collaboration, gaming, financial tickers, and notifications. The persistent connection eliminates the overhead of repeated HTTP handshakes.
Why It Matters
WebSockets enable real-time features that would be inefficient or impossible with traditional HTTP polling. Understanding when WebSockets are appropriate helps architects design responsive applications.
However, WebSockets require more complex server infrastructure and connection management.
Examples in Practice
A collaborative document editor using WebSockets to sync changes between users instantly.
Live sports scores updating automatically as events happen, without page refreshes.
Chat applications maintaining persistent connections for instant message delivery.