Author here. I wrote a post about the design of this game on my blog: https://jvns.ca/blog/2021/04/16/notes-on-debugging-puzzles/
The Case of the 50ms request
81–88 of 88 posts
Re: The Case of the 50ms request
#82Knowledge of delayed ack and nagle's algorithm wasn't necessary to solve. The explanation didn't mention the flushHeaders call, which is apparently the fix. I didn't run any tests, just looked at the JS and figured that sending 2 packets is worse than sending 1 w.r.t. latency. It's also a pretty strong intuition that the client side tends to have issues, since the server is usually well-tested and standardized. Also,…
There's a huge difference between solving an instance of a problem and understanding the problem. Enough commits of "this seems to fix the problem" and the codebase becomes really hard to work with.
In this case, in my judgement, you only need to know about the delayed-ack/Nagling concepts if there's a engineering requirement to keep the flushHeaders call, and the 50ms latency is a dealbreaker (i.e. not merely a curiosity). Even then, it's not clear how to fix unless you can disable one of those features.
Re: The Case of the 50ms request
#83Asked what to do about it and typed 'tcpnodelay'. It replied it wasn't smart and asked me to click a button.
Feels pretty basic to anyone who's ever really touched TCP in code.
Re: The Case of the 50ms request
#84The interesting thing for me is that I would suspect most devs including myself would assume that if the request takes 50ms, that's how long it takes (because networks!). I wonder how many of us are able to judge how long something should take? Not me, except anecdotally.
Re: The Case of the 50ms request
#85Delayed ACKs can be enabled on Linux kernels 3.11+ with ip(8).
ip route change ROUTE quickack 1
On MacOS and Windows, delayed ACKs can be configured through sysctl and the registry, respectively.Delayed ACKs may be used in response to congestion.
For example, in bulk, i.e., non-interactive, transfers with large packets, delayed ACKs can be useful.
This is covered in Chapters 15 (15.3) and 16 of Stevens' TCP/IP Illustrated Vol. 1.
This draft suggests delayed ACKs are useful during TLS handshake.
https://tools.ietf.org/id/draft-stenberg-httpbis-tcp-03.html
Also, socat allows for setting TCP options via setsockopt. No need to write a new program.
Re: The Case of the 50ms request
#86"Also, the Linux kernel doesn't always enable delayed ACKs -- to reproduce this I actually had to write a Python program that explicitly turns them on. I haven't been able to find a clear explanation of exactly when delayed ACKs are used." Delayed ACKs can be enabled on Linux kernels 3.11+ with ip(8). ip route change ROUTE quickack 1 On MacOS and Windows, delayed ACKs can be configured through sysctl and the registry…
ip route change ROUTE quickack 1 dev STRINGRe: The Case of the 50ms request
#87I got it straight away, but I have a telecoms engineering and networking background. This just goes to show how poorly networking is taught in most courses (as are databases), and specially in boot camps. Self-taught programmers are also very unlikely to be exposed to this kind of topic. One thing that was not offered as an option was to use a packet analyzer like tcpdump or Wireshark, even though that is the most re…
If you're talking about the game, then there is the option to use tcpdump directly on the client.