4

So this question has been asked four years ago, when websockets weren't supported by many browsers back in 2011 here -> Build a whole site using just websockets (via socket.io and node.js, no Ajax)?

And with the reduction of the size of http headers websockets provide and four years of further development since that question has been asked, would a website build only with websockets help performance and network latency with smaller headers? the initial handshake would occur during a login phase and the connection would timeout after a time period or during logout. So once again, would a website, social network, with real time chat or push notifications benefit from being built solely out of websockets vs http?

Community
  • 1
  • 1
Adam S
  • 43
  • 4
  • 2
    webSocket vs. Ajax are a tradeoff that depends upon the usage scenario. If you're making regular and frequent and constant ajax-like calls from client to server, then you may well benefit from having a continuous connection with a webSocket. But, if the client usage is sporadic and not constant, then it may be less scalable and more complicated to maintain continuous TCP connections to a large number of clients than it is to process temporal ajax calls. A websocket connection is less efficient to initiate (it starts with an http connection), but more efficient to use once established. – jfriend00 Mar 23 '15 at 05:21

1 Answers1

0

Real time chat and push notifications are a good candidate for websockets, and it is quite possible they scale better than ajax. See this question: Do HTML WebSockets maintain an open connection for each client? Does this scale?

Just don't needlessly force every functionality of your website to fit into your websockets-centric architecture if ajax is a better solution in that situation.

Community
  • 1
  • 1
newprogrammer
  • 2,514
  • 2
  • 28
  • 46