News for hackers. Stuff that matters.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by eightnoteight on Monday March 18, 2024 @03:27PM (#39748840)
websockets and sse are a big headache to manage at scale, especially backend, requires special observability, if not implemented really carefully on mobile devices its a nightmare to debug on frontend side

devices switch off network or slow down etc,... for battery conservation, or when you don't explicitly do the I/O using a dedicated API for it.

new connection setup is a costly operation, the server has to store the state somewhere and when this stateful layer faces any issue, clients keep retrying and timing out. forever stuck on performing this costly operation. it's not like there is an easy way to control the throughput and slowly put the load on database

reliability wise long polling is the best one IME, if event based flow is really important, even then its better to have a 2 layer backend, where frontend does long polling on the 1st layer which then subscribes to websockets to the 2nd layer backend. much better control in terms of reliability

Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by debarshri on Monday March 18, 2024 @03:32PM (#39748904)
I cannot agree more with you. I have seen people shot themselves on foot with Websockets and SSE. Long Polling even though is expensive, is it most explainable and scalable approach in my opinion.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by pornel on Monday March 18, 2024 @08:17PM (#39751621)
SSE supports long polling. You can make the server close the connection whenever you want. SSE supports automatic reconnection, and will even include the last ID seen to let the server continue seamlessly.
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by hobobaggins on Monday March 18, 2024 @08:36PM (#39751751)
It's important to remember that SSE won't automatically reconnect for quite a few HTTP status codes (i.e., upstream proxy outages like 50x error codes)
Re:WebSockets vs. Server-Sent-Events vs. Long-Polling vs. We... by nchmy on Tuesday March 19, 2024 @11:03AM (#39756447)
A lot of this was addressed in the linked article - rxdb has mechanisms to mitigate many of your concerns...