Why use websocket and what is its advantage?

I have tried reading some articles, but it is not that clear on this topic.

Someone would like to explain to me below:

  • Why use websocket over http
  • what is full duplex communication.
  • What do you mean by the impact of lower latency?

Any form of help is greatly appreciated.

+3


source to share


1 answer


Why use websocket over http?

WebSocket is an end-to-end connection between client and server. This continuous connection allows:

  • Data can be sent from the server to the client at any time, even if the client doesn't even request it. This is often referred to as server push and is very valuable for applications where the client needs to know quickly enough when something is happening on the server (for example, new chat messages have been received or a new price has been blown). The client cannot transfer data over http. The client had to poll regularly, making an HTTP request every few seconds to get timely new data. Customer survey is ineffective.

  • Data can be sent in any way very efficiently. Since the connection has already been established and the webSocket data frame is very efficiently organized, it is possible to send data much more efficiently using an HTTP request that necessarily contains headers, cookies, etc.

what is full duplex communication?

Full duplex means that data can be sent anyway at any time.

what do you mean by lower latency impact



Low latency means there is very little latency between the time you ask for something and the time you receive a response. As it applies to web sockets, it simply means that data can be sent faster (especially over slow links) since the connection is already established, so no additional packet hits are required to establish a TCP connection.

For comparison in what has to do with sending some data through an HTTP request and having a websocker connection already established, see the steps listed in this answer: websocket vs rest API for realtime data?

These other links may be helpful as well:

Server call on function call: Ajax or WebSockets

Push Notification | is a website required?

HTML5 WebSocket: A quantum leap in scalability for the web

+9


source







All Articles