Edge Academy


WebSocket is a protocol for creating a fast two-way channel between a web browser and a server that overcomes the limitations of HTTP, offering low latency communications between a user and a web service.


As Internet speeds continue to climb, users are beginning to see the Internet as a source of dynamic, real-time information. Like desktop applications, the web traditionally relied on the user to perform an action before the service could process and provide information. While this works, it creates a static experience and prevents users from becoming truly engaged in the content.

WebSockets adds flavor to the web by allowing websites to update content without having to wait for the user. Unlike other techniques which piggyback on the HTTP protocol, the WebSocket protocol creates a true ongoing connection between the user and the web service, allowing information to flow easily between both endpoints.

WebSocket compared to other technologies

Several paradigms have been created to facilitate two-way communication between a browser and a server. One of the biggest differences between these approaches and WebSocket is that these approaches still rely on HTTP whereas WebSocket is its own protocol.


Asynchronous JavaScript and XML (AJAX) is a technique for updating the content of a page without refreshing the entire page. Rather than interrupt the user’s session, AJAX modifies part of the web page as it appears in the user’s browser. The browser can communicate any changes to and from the server without having to reload the entire page.

The drawback to AJAX is that it’s still a one-way communication. The server can’t push data to the user. Instead, the user has to poll the server for changes. Additionally, since AJAX works over HTTP, a new connection has to be created each time an AJAX request is made.

WebSockets overcomes both of these limitations by establishing a persistent connection that the server can push data over.


Webhooks allow a web service to send data to another service when a particular event occurs. They make it possible for services to instantly communicate with each other, allowing those services to process and respond to events as they happen. Unlike AJAX, Webhooks are entirely server-side and don’t interact with the user’s experience.

Webhooks can only facilitate one-way communication between two services. A server must be configured to transmit Webhooks and another to receive them. Webhooks are great for services that want to communicate with other services, but not for services that want to communicate with users.

WebSockets can facilitate two-way communication between a user and a service, recognizing events and displaying them to the user as they occur.

Example of WebSocket

In 2013, Google released World Wide Maze (WWM), a game that turns web pages into a 3D maze. Built on WebSockets, WWM uses Chrome to turn a mobile device into a controller while displaying the output to a monitor or TV. Two persistent connections allow Google to receive input from the controller, build the game’s stage, and route the controller’s actions to the output device in under 200 milliseconds.

Google’s developers aren’t the only ones creating real-time interactive experiences with WebSockets. Plink is a multi-user soundboard for creating electronic music. Users select a username and color, then create sound by clicking their cursor along a grid. For a more business-oriented approach, Quip allows multiple users to edit the same documents at the same time. Using WebSocket, these apps allow users to instantly push and receive updates.

Benefits of WebSocket

WebSocket brings truly instant communication to the web, making websites look and feel more like local applications.

  • Users enjoy a seamless, uninterrupted experience since their browser is constantly communicating with the server, delivering new content immediately rather than when it’s requested.
  • Enterprises see higher customer satisfaction and engagement as customers enjoy a more dynamic and fluid experience.


As the line blurs between websites and applications, consumers expect their data to be delivered quickly and without interruptions. With WebSockets, service providers can create a powerful, low latency channel between their content and their customers.

Note: To achieve the lowest possible latency with WebSocket, you can proxy your WebSocket connections through StackPath's CDN by enabling a setting in your CDN Stack. More info here.

Related Products
Request Demo

Have questions? Chat now with the live chat button on this page or request a demo from our edge experts.

Request a Demo
Get an Advantage

Stay informed of the latest edge news, updates and solutions.