05/27/2022
What is the difference between Web Sockets and REST?
β Web Socket is a stateful protocol, whereas REST is based on a stateless protocol, i.e. the client does not need to know about the server, and the same hold true for the server.
β Web Socket connection can scale vertically on a single server, whereas REST, which is HTTP-based, can scale horizontally.
β is ideal for a scenario where high loads are a part of the game, i.e. real-time scalable chat application, whereas REST is better fitted for occasional communication in a typical GET request scenario to call RESTful APIs.
β Web Socket works better, where the client-server communicates over the same TCP connection for the life of the web socket connection, whereas, for an HTTP request, a new TCP connection is initiated.
β Web Socket communication allows the client and server to talk independently of each other, whereas with the REST-based approach, either the client is talking to the client or the server is talking to the client.
β Web Socket communication cost is lower, whereas REST-based communication is comparatively higher end of the cost. (EDUCBA)