3

I have seen a lot of people have written Ajax(polling) vs websocket. I have not seen anyone mentioned below disadvantage of websocket.

As we know for each http request web-server needs connection.There are maximum number of concurrent connections web-server can support,beyond that if a request comes,request will have to wait till any connection is fee.

I case of simple http request(poll based),when a request is served by server connection is put in pool and that connection can be used for next request,so it is very unlikely in simple http request,a request will be waiting for a connection.

But in websocket connection is never put back in pool of webserver,so it is going to very frequent that next request will have to keep waiting for ever for connection.

So,I want to know,Am i thinking correctly or missing something. I am correct,how this is solved?does this issue ever occur?

Nishat
  • 881
  • 1
  • 17
  • 30

1 Answers1

0

Browser can pool HTTP connections by using Connection: Keep-Alive header and then reuse them for further requests to the same host.

But WebSockets are not about requests and it's connections are not shared. You connect to WebSocket server and then control communication in your code. And that's all. If you want another connection, then you should create it.

Also, existing HTTP connections from pool can be upgraded to WebSocket connections.

berserkk
  • 987
  • 6
  • 11