4 ms·
Decreased battery life, because you have to actively keep polling. Either WebSockets or even real TCP sockets would make that a lot better. Also, it means that
by sham1 3y ago
Decreased battery life, because you have to actively keep polling. Either WebSockets or even real TCP sockets would make that a lot better.
Also, it means that a server can't really push events at you, especially if they're coming in rapidly, as they might be with a sufficiently active community. Like sure, once you're waiting for the server response for your long poll request, you'll get the data, but between receiving the data and the next time you poll, there's bound to be stuff happening in your chat room that you'll only know about the next time you poll. Of course with that, you wouldn't need to poll for long, but that also causes problems with battery.
In contrast WebSockets or even raw, real TCP sockets the server can just push stuff at you.
- Gigachad 3y agoThose polls sit suspended for quite a long time. I can’t imagine it moves the needle at all on battery life. Just open reddit and it fires off more network requests than an entire day long polling. The timing also isn’t fixed. It isn’t like you only receive data on the poll interval. The request finalises when data comes in and a new one is created instantly. So I can’t imagine there being more than a second delay for receiving messages which is entirely acceptable for the use case. If nothing is happening, you’d only be making a request every couple of minutes, but in an active chat it’s perfectly capable of making them continuously. And for mobile, it isn’t long polling while the app is closed, it’s using the regular push notifications system.