3 ms·
In present time, is there an advantage of long polling pattern vs web socket?
by jordache 8y ago
In present time, is there an advantage of long polling pattern vs web socket?
- napsterbr 8y agoJust the fact that it's stateless and therefore may result in a simpler application and infrastructure. But I belive that, in this case, the pros of websocket outweigh its cons. That said, I've been working with a middle ground: http 2 + sse. Gives the benefit of simpler infrastructure while not being as inefficient as short/long-polling. ETA: after using websocket for a while, one of the major downsides is that you can't use most of the http ecosystem. Stuff like cloudflare workers, cloudflare anti-ddos[0], swagger api docs, caching etc. I recently switched to http 2 + sse and do not regret. [0] - they do support websockets, but at a limited and undisclosed rate (I.e. You don't know how many is too many until they ask you to upgrade your plan).
- nitwit005 8y agoIf you support HTTP2, the long poll requests will generally reuse a connection. Websockets consume a connection, which can result in hitting issues with opening a lot of tabs. There was a proposal to make it compatible with HTTP2, but I don't believe it went anywhere.