Score:0

How to set request timeouts at every network hop

ec flag

I'm trying to wrap my head around network timeouts and how they should be set for each hop of a given request. For simplicity, I'm not looking at a breakdown of connect vs. read vs. write timeouts and will assume "timeout" means "max allowed total time from first packet received to last packet sent (or vice-versa for the client). Say I have the following hops in my request flow:

(client) --> (AWS ALB) --> (nginx) --> (server)

…and let's assume that my server is set up to timeout after 10 seconds.

My question: what would be a valid set of timeouts for every hop? Would it be

// A
(client, 13s) --> (AWS ALB, 12s) --> (nginx, 11s) --> (server, 10s)

or

// B
(client, 7s) --> (AWS ALB, 8s) --> (nginx, 9s) --> (server, 10s)

or (C) something else?

Obviously, I'm also interested in the logic behind your suggestions.

Score:1
ru flag

If you're looking at hard timeouts (you don't state the purpose), each processing stage has less time than the previous one. So basically, A is the right approach.

However, the client-to-AWSALB path is beyond your control and may be comparatively lengthy/slow. One second per steps seems very generous, so no problem there. But if you decrease that to 50 or perhaps 100 ms per step, the first step will need some more allocation.

caccialdo avatar
ec flag
Thanks Zac - this is also what feels the most intuitive to me. However, one thing I didn't mention in the original post is that I found [this recommendation](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#connection-idle-timeout:~:text=We%20also%20recommend,connection%20is%20closed.) in AWS docs for ALBs that seem to imply that B should be preferred. I could be misunderstanding their sentence though, or it could be a recommendation for a different scenario than hard timeouts.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.