News for hackers. Stuff that matters.
Re:Don't trust default timeouts by hodgesrm on Saturday August 29, 2020 @08:49PM (#24320469)
"Don't trust timeouts" is a better title and a better approach. The fundamental problem with distributed systems is you can't tell the difference between slow and non-responsive/crashed services. Simple timeouts are rarely the answer. Here are the obvious ones depending on what part of the problem you are trying to optimize.

* Keepalive - Have the server ping back on a short timeout while it's working. Use a very long timeout for the server response.

* Asynchronous queues - Use queues for requests and discard traffic/error out when the queue becomes full.

* Idempotence - Send another request if the first one does not return in a reasonable amount of time.

* Broadcast - Don't fetch the information, have it sent to you through UDP. Great for cumulative metrics. If you miss one, no problem, the next packet has the same data.

* Cancellation - Cancel the request if you don't get an answer.

* Multiple requests - Send requests to multiple services and return the one that gets back first.

Forcing clients to pick timeouts amounts to punting a hard problem over to somebody who has even less idea how to solve it than you do.

Edit: clarity

Re:Don't trust default timeouts by ric2b on Sunday August 30, 2020 @07:17AM (#24322660)
Great list.

That last suggestion (Multiple requests) can be tough to implement correctly, I think it's usually called Happy Eyeballs: https://youtu.be/oLkfnc_UMcE?t=290