Score:0

Drawbacks of keeping outbound connections open with long timeout values

nl flag

Keeping connections open obviously consumes resources even though they're just TCP connections sitting there, waiting response.

It is also obvious that they don't consume as much compared to, say, a process making database queries and transforming results to create a response.

My issue is, when I calculate potential resource consumption of raising timeout values, what i take into account seems to yield an optimistic result and I'd like to know if I'm missing anything.

I explore this by thinking as if the operation will end successfully and with identical results either way. Imagine we'll either raise the timeout values or magically get the external server respond faster. So that we can isolate the effects of keeping the connection open for longer. Then I can, separately compare them to the effects of the process not being completed.

Things I consider are:

  • Memory consumption: I find this to be the most concerning one. However when the open connection spends almost all it's time waiting for a payload, it has allocated the minimum amount of memory of it's life cycle.
  • CPU usage: Next to zero. The process itself just checks if the response is there yet. The OS should be maintaining the connection but can't think of any significant calculations
  • Concurrent open connections: A light research says the limit is around .3 million. If my number gets nowhere near that, we're cool
  • Socket count: Again, if my system is nowhere near the limit, it's ok
  • Port count: Same: We know the limit, we know if we're pushing it.
  • Max number of open files: We can test how much we need for each process and calculate accordingly
  • Keeping other services busy: We may be keeping a database connection busy, an inbound connection waiting for our process etc.

This is all I can come up with as drawbacks. In my case every item besides memory isn't even worth making calculations and memory consumption is not affected that much anyway.

When I compare this to not being able to complete the operation, the scale tips way further towards raising the timeouts. In our specific situation if the operation fails, the next request will take even longer trying to compensate, which kind of includes the entirety of drawbacks of high timeouts. Having raised the timeouts, the total time spent waiting would be even less.

This became a light debate with my boss who seems to think this issue is (or I am) below him to be worth arguing. Can't get anything constructive out of that conversation so I came here.

Is there any notable aspects that I've missed? Is any of my items being underestimated?

pt flag
Since you're not able to demonstrate an actual problem here, this question is going to mostly be an opinion question, and hence not really appropriate for this site. Open connections certainly do consume resources (available file descriptors, memory), but in many environments the per-connection resource utilization is small and the total number of connections is small, so it doesn't matter. Whether this is a problem in your *specific* environment really depends on your application and the amount of traffic you're serving (and you're available resources).
timuçin avatar
nl flag
I too was hesitant to ask something so vague here but didn't know where else to go and made a judgement call. I'll check the guidelines again and possibly delete the question. Having said that, again, I get "Open connections certainly do consume resources". I don't know how people manage to think I'm saying otherwise. I can't come up anything better than openly saying that I know they do. Apparently I need to find something better though.
timuçin avatar
nl flag
I read the guidelines and decided this question barely (if at all) fits to be on this site. I'll either have to provide comprehensive details about the environment or move the focus to the "what are the ways this affects performance" aspect rather than "could this hurt our system". thanks @larsks for their feedback. I'll also turn down the ranty tone. The last thing I wish is to litter this site.
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.