WebSocket

Last update:2022-03-17 10:08:11

1 Feature Intro

1.1 Brief Introduction

WebSocket is a computer communication protocol which provides full-duplex communication channels over a single TCP connection. It mainly solves the problem that the client cannot obtain updated data from the server in time under the traditional HTTP communication, and establishes a two-way connection between the client and the server to enrich web application functionality based on event, improving timeliness and application performance.

1.2 Applicable Product Lines

  • Dynamic Web Acceleration
  • Media Acceleration Live Broadcast

1.3 Application Scenarios

WebSocket is especially useful under below scenarios when concurrency and real-time response requirements are high:

  1. Social subscriptions update and notification in real time;
  2. Real-time interaction on social media platform;
  3. Real-time data and trends display of stock funds;
  4. Sports live update;
  5. Instant message and live chat;
  6. Location-based app (such as navigation app)

2 Feature Detail

In the process of implementing WebSocket connection, the client first needs to initiate a WebSocket connection request, and then the server returns a response. This process is called “handshake”. After the handshake is successful, the client and the server establish a full-duplex communication channels to transfer data to each other.
The comparison between Traditional HTTP and WebSocket Interactions

Traditional HTTP Solutions:

  1. Round robin: The client sets a time interval and periodically sends a request to the server for new data, and the server immediately returns a response with or without new data.
  2. Long polling:The client sends a request for new data, and the server blocks the request and does not respond until the new data is available.

WebSocket:

When the connection is established, the client and the server will maintain persistent connection. Once the data is updated, the server will proactively push it to the client.

3 Key Benefits

  1. Solve the problem that the client cannot obtain the updated data from the server in time.
  2. Enrich Web application functionality to improve user experience and application performance.
  3. Greatly reduce the consumption of network bandwidth resources when concurrency is massive and traffic load is heavy between the client and the server.
Is the content of this document helpful to you?
Yes
I have suggestion
Submitted successfully! Thank you very much for your feedback, we will continue to strive to do better!