I know there are a lot of questions and also answers around the TIME_WAIT
state of a socket connection, but somehow non of them (or maybe from an experts perspective all of them) help me to understand my problem (or find possible solutions).
My scenario is, that I have a server facing the internet, which has to handle thousands of connections per second (it provides some type of API). I observe, that connections to the server are generally possible, but the time_connect
and the time_total
(using curl
) are reaching from 0.009
to 0.526
for the former and 0.134
to 0.926
for the latter. I also observe a massive amount of connections in TIME_WAIT
state - around 32,000+
.
So my first question is, how many concurrent connections (with a default configured Debian distribution) can a server handle within a second, a minute or an hour. Is there some "simple" formula to calculate the logical limit of possible concurrent connections.
Furthermore, in the future I may not just handle an incoming connection directly on the server itself, instead I may have to forward it to a proxy, get the result and return it. I'm even thinking of utilizing the load-balancing mechanism of nginx (if needed). The second questions is therefore, having such a proxy/load-balancing/forwarding in place, how would the formula have to be modified?
My last question would be, what alternatives are there to increase the number of concurrent connections, e.g.,
- add another server for the domain (that would double the amount of concurrent connections correct?),
- decrease the time spent in
TIME_WAIT
(would that help and how), - ...
Thanks a lot for any help, or any reference!