abdul aleem
abdul aleem

Reputation: 27

resource comparison between socket.io vs rest api

I am building application on socket.io and node.js expressjs 4 . for my opinion socket.io takes much resources then Rest APIs. I want to know how i can compare RestApis vs Socket.io in terms of memory ,CPU usage .and which is best for large applications Thanks

Upvotes: 2

Views: 3386

Answers (2)

baydi
baydi

Reputation: 1003

You might get help from mention below blogs

http://www.pubnub.com/blog/websockets-vs-rest-api-understanding-the-difference/

http://blog.arungupta.me/rest-vs-websocket-comparison-benchmarks/

These contion the complete detail of the difference.

Upvotes: 0

To compare memory and CPU usage i suggest executing a big number of queries of each one separately (like a thousand) and watching the memory and cpu of the process. Now which is better it's not that simple. It all depends... Socket.io is designed to be a real-time tool, so in large applications where there are a lot of real-time operations, it's better. But in large applications where real-time is really not an issue i believe(never really tested to know the numbers) you can get lesser memory usage using RESTful APIs, mainly because websocket is stateful, so the server needs to have every connection in it's memory. Another thing to put in mind is that HTTP protocol has a lot of goodies that websocket doesn't like gzipping, cache, routing, SEO, proxy, and much more.

A good article about that: REST vs WebSocket

Upvotes: 2

Related Questions