justcoding121 / titanium-web-proxy

A cross-platform asynchronous HTTP(S) proxy server in C#.
MIT License
1.93k stars 618 forks source link

What is EnableConnectionPool? #781

Closed phillijw closed 4 years ago

phillijw commented 4 years ago
        /// <summary>
        ///     Should we enable experimental server connection pool?
        ///     Defaults to true.
        /// </summary>
        public bool EnableConnectionPool { get; set; } = true;

Is this setting up connections to the remote proxy servers? How many will it set up? Where can I find some more info on this, as trying to trace back the code is getting me confused.

justcoding121 commented 4 years ago

When you enable connection pooling, instead of creating a new TCP connection to server for each client TCP connection, we check if a server connection is available in our cached pool. If it is available in our pool, created from earlier requests to the same server, we will reuse that connection. There is also a ConnectionTimeOutSeconds parameter, which determine the eviction time for inactive server connections. In that way, we reduce the TCP connection establishment cost, both the wall clock time and CPU cycles. It was experimental when it was implemented years ago, now that it is stable and is enabled by default, we will update the docs.

phillijw commented 4 years ago

Thanks for the info. I notice that the number in the pool seems to be higher than the total number of proxies available. Does it connect multiple times to the same server? There seems to be about a 3:1 ratio in my case

justcoding121 commented 4 years ago

It depends. If you had 3 concurrent client connections to the same server at some point, it will stay in the pool even after client connections has dropped, until its evicted by timeout. Not sure what you mean by total proxies available.