Reputation: 3511
In a single page application: When using ajax, the ajax request gets the data and the connection is closed. This allows thousands of users to use the system.
In web sockets, each "page" opens a socket connection (to a namespace) and keeps it live however this has thousands of idle connections, this can't be good for performance?
Also, doing tests on firefox, the ajax connection is 20ms latency while each call in socket.io connection is 200ms.
Upvotes: 3
Views: 7466
Reputation: 63653
You have to consider what's your situation. WebSockets aren't an alternative to Ajax, they serve a different purpose. WS are good when you need long running connections, for example when you are making chats or real-time websites (like livescore for ex.)
If you are wondering how many connections can Socket.IO handle, there is a similar question here (short version: depends on hardware):
Socket.io: How many concurrent connections can WebSockets handle?
Upvotes: 3