Answer» | REST | Web Socket |
|---|
| REST follows STATELESS architecture, meaning it won’t store any session-based data. | Web Socket APIs follow the stateful protocol as it necessitates session-based data storage. | | The mode of communication is uni-directional. At a time, only the server or the client will communicate. | The communication is bi-directional, communication can be done by both client or server at a time. | | REST is based on the Request-Response Model. | Web Socket follows the full-duplex model. | | EVERY request will have sections like header, title, body, URL, etc. | Web sockets do not have any overhead and hence suited for real-time communication. | | For every HTTP request, a new TCP connection is set up. | There will be only ONE TCP connection and then the client and server can start communicating. | | REST web services support both vertical and horizontal scaling. | Web socket-based services only support vertical scaling. | | REST depends on HTTP methods to get the response. | Web Sockets depend on the IP address and port number of the system to get a response. | | Communication is slower here. | Message transmission happens very faster than REST API. | | Memory/Buffers are not needed to store data here. | Memory is REQUIRED to store data. |
The request FLOW difference between the REST and Web Socket is shown below:
|