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. |