WebSockets

Let's learn about the WebSocket protocol and discuss its pros and cons.

Motivation

Most web APIs use HTTP as their underlying protocol to transfer data, and HTTP is often considered as one of the best options for executing batch tasksTasks that can be grouped together but performed independently and do not require an immediate response based on input factors. asynchronously. But when it comes to two-way and real-time communication such as chat, live streaming, gaming, and so on, HTTP falls short because it is a request-response protocol, where usually a server closes the connection after sending the response. We describe some HTTP-based techniques and their corresponding limitations in achieving bidirectional communication in the table below:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.