0

In case of 100 concurrent connections with the same host, which could be repeating in time, would it make sense to set MaxIdleConnsPerHost to 100?

What could be a suitable value in order to avoid a big amount on unreusable TIME_WAIT status on the connection?

Daniele B
  • 19,801
  • 29
  • 115
  • 173
  • You really need to stop worrying about TIME_WAIT ;) It's a red herring. Plus MaxIdleConnsPerHost is a client config option, not a server. – JimB Mar 19 '14 at 20:38
  • Hi @JimB :) actually this time I am talking about the http requests I am making to the external server. I am doing many cuncurrently, and TIME_WAITs add up. So I was wondering if it makes sense to raise the MaxIdleConnsPerHost value. – Daniele B Mar 19 '14 at 20:50

1 Answers1

2

As I mentioned, TIME_WAIT is't something you shouldn't worry about in this context. It's also usually not something you worry about until you actually need to, and a few systems setting usually take care of that outside of your code.

If your service is very busy, you're going to be best served by making your software as efficient as possible regardless. HTTP1.1 keepalive connections are one way to do this if you make many repeated calls to the same hosts. That said, 100 idle connections might be just fine for what you need; or it might be more than the remote service is willing to let you keep open (unless you control that too).

Measure, test, and benchmark, then figure out what sort of capacity you're going to need.

JimB
  • 104,193
  • 13
  • 262
  • 255