News for hackers. Stuff that matters.
Re:Back to basics: Why we chose long-polling over websockets by wutwutwat on Sunday January 05, 2025 @03:46PM (#42604888)
Every problem you just listed is 100% in your control and able to be configured, so the issue isn't long polling, it's your setup/configs. If your client (libcurl) times out a request, set the timeout higher. If apache is your web server and it disconnects idle clients, increase the timeout, tell it not to buffer the request and to pass it straight back to the app server. If there's a cloud lb somewhere (sounds like it because alb defaults to a 10s idle timeout), increase the timeouts...

Every timeout in every hop of the chain is within your control to configure. Setup a subdomain and send long polling requests through that so the timeouts can be set higher and not impact regular http requests or open yourself up to slow client ddos.

Why would you try to do long polling and not configure your request chain to be able to handle them without killing idle connections? The problems you have only exist because you're allowing them to exist. Set your idle timeouts higher. Send keepalives more often. Tell your web servers to not do request buffering, etc.

All of that is extremely easy to test and verify functioanlity. Does the request live longer than your polling interval? Yes? Great you're done! No? Tune some more timeouts and log the request chain everywhere you can until you know where the problems lie. Knock them out one by one going back to the origin until you get what you want.

Long polling is easy to get right from an operations perspective.

Re:Back to basics: Why we chose long-polling over websockets by moritonal on Sunday January 05, 2025 @04:42PM (#42605301)
Whilst it's possible you may be correct, I do have to point out you are, I believe, lecturing John Nagle, known for Nagle's algorithm, used in most TCP stacks in the world.
Re:Back to basics: Why we chose long-polling over websockets by motorest on Sunday January 05, 2025 @05:36PM (#42605651)
> Whilst it's possible you may be correct, I do have to point out you are, I believe, lecturing John Nagle, known for Nagle's algorithm, used in most TCP stacks in the world.

Thank you for pointing that out. This thread alone is bound to become a meme.

Re:Back to basics: Why we chose long-polling over websockets by wutwutwat on Sunday January 05, 2025 @05:49PM (#42605744)
Oh fuck a famous person!? I told a famous person to adjust their server timeouts?!!

This changes everything!

I better go kill myself from this embarrassment so my family doesn't have to live with my shame! Hopefully with enough generations of time passing my family will rise above the stain I've created for them!

Re:Back to basics: Why we chose long-polling over websockets by moritonal on Sunday January 05, 2025 @08:03PM (#42606516)
I'm sorry, I didn't mean to embarrass you. I only meant to point out that people would err on the side of John likely knowing what they were talking about, whilst you seem to confidently have some misunderstandings in your comment.

For example, you said "Every timeout in every hop of the chain is within your control to configure", but I'm quite confident that the WiFi router my office uses doesn't respect timeouts correctly, nor does my Phone's ISP, or certain VPNs. Those "hops" in the network are not within my control at all.

Re:Back to basics: Why we chose long-polling over websockets by motorest on Sunday January 05, 2025 @05:54PM (#42605769)
> I better go kill myself from this embarrassment so my family doesn't have to live with my shame!

There's no need to go to extremes, no matter how embarrassing and notably laughable your comment was. I'd say enjoy your fame.

Re:Back to basics: Why we chose long-polling over websockets by KronisLV on Monday January 06, 2025 @07:46AM (#42610119)
> There's no need to go to extremes

Agreed, honestly if an argument is made and it makes sense, it doesn't matter who is on the other side.

> no matter how embarrassing and notably laughable your comment was.

I wouldn't even call the original comment laughable, they had a point - if you are in control of significant parts of the overall solution, then you can most likely mitigate most of the issues. And, while not a best practice, there's nothing really preventing you from sneaking in the occasional keepalive type response in the stream of events, if you deem it necessary.

The less of the infrastructure and application you control, the more likely the other issues are likely to pop up their heads. As usual, it depends on your circumstances and both the original comment and the response are valid in their own right. The "extreme" response was a bit more... I'm not sure, cringe? Oh well.

Re:Back to basics: Why we chose long-polling over websockets by rezmason on Sunday January 05, 2025 @05:54PM (#42605772)
I bet there's an online college credit transfer program that'll accept this as a doctoral defense. Depending on how Nagle's finagled.
Re:Back to basics: Why we chose long-polling over websockets by exe34 on Sunday January 05, 2025 @05:46PM (#42605719)
Oh my gosh :-D
[dead]
Re:Back to basics: Why we chose long-polling over websockets by conradfr on Sunday January 05, 2025 @06:15PM (#42605887)
But it's easier to lecture someone on a bug they already diagnosed and explained to you.
Re:Back to basics: Why we chose long-polling over websockets by wutwutwat on Sunday January 05, 2025 @06:46PM (#42606076)
We must be reading different comments
Re:Back to basics: Why we chose long-polling over websockets by Animats on Sunday January 05, 2025 @10:35PM (#42607393)
He has a valid criticism. It's not that it can't be fixed. It's that it's hard to diagnose.

The underlying problems are those of legacy software. People long gone from Linden Lab wrote this part of Second Life. The networking system predates the widespread use of middle boxes. (It also predates the invention of conflict-free replicated data types, which would have helped some higher level consistency problems.) The internal diagnostic tools are not very helpful. The problem manifests itself as errors in the presentation of a virtual world, far from the network layer. What looked like trouble at the higher levels turned to be, at least partially, trouble at the network layer.

The developer who has to fix this wrote "This made me look into this part of the protocol design and I wish I hadn't."

More than you ever wanted to know about this: [1] That discussion involves developers of four different clients, some of which talk to two different servers.

(All this, by the way, is part of why there are very few big, seamless, high-detail metaverses. Despite all the money spent during the brief metaverse boom, nobody actually shipped a good one. There are some hard technical problems seen nowhere else. Somehow I seem to end up in areas like that.)

[1] https://community.secondlife.com/forums/topic/503010-obscure...

Re:Back to basics: Why we chose long-polling over websockets by tbillington on Sunday January 05, 2025 @05:19PM (#42605531)
> Every timeout in every hop of the chain is within your control to configure.

lol

Re:Back to basics: Why we chose long-polling over websockets by wutwutwat on Sunday January 05, 2025 @05:35PM (#42605649)
I wasn't talking about network switch hops and if you're trying to long polling and don't have control over the web servers going back to your systems then wtf are you trying to do long polling for anyway.

I don't try to run red lights because I don't have control over the lights on the road.

Re:Back to basics: Why we chose long-polling over websockets by earnestinger on Sunday January 05, 2025 @06:21PM (#42605927)
Thus, the advice to not run the red light..
Re:Back to basics: Why we chose long-polling over websockets by wutwutwat on Sunday January 05, 2025 @06:39PM (#42606032)
What the fuck are you even talking about. The comment I replied to originally was saying long polling has flaws, then proceeded to talk about timeouts in their server software, which isn't the fault of long polling, and is in their control to change the values of.
Re:Back to basics: Why we chose long-polling over websockets by luma on Sunday January 05, 2025 @07:42PM (#42606388)
Re-read the post, there’s more in the path than just your client and server code, and network switches aren’t the problem. The “middle boxes and proxy servers” are legion and you can only mitigate their presence.

You’ve been offered the gift of wisdom. It’d be wise on your part to pay attention, because you clearly aren’t.