summary refs log tree commit diff
path: root/synapse/http/client.py
diff options
context:
space:
mode:
authorPatrick Cloke <patrickc@matrix.org>2023-05-24 15:09:54 -0400
committerPatrick Cloke <patrickc@matrix.org>2023-05-30 15:04:26 -0400
commitb14f5f1fb5853eeb66764d5074877d10461524fd (patch)
treea7ef7521c3eb74b81c02ebb4895779fd3fb652ce /synapse/http/client.py
parentMerge branch 'release-v1.85' into develop (diff)
downloadsynapse-b14f5f1fb5853eeb66764d5074877d10461524fd.tar.xz
Reduce the size of the HTTP connection pool for non-pushers.
Diffstat (limited to 'synapse/http/client.py')
-rw-r--r--synapse/http/client.py14
1 files changed, 3 insertions, 11 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 09ea93e10d..ef27dab85e 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -761,6 +761,7 @@ class SimpleHttpClient(BaseHttpClient):
            request if it were otherwise caught in a blocklist.
         use_proxy: Whether proxy settings should be discovered and used
             from conventional environment variables.
+        connection_pool: The connection pool to use for this client's agent.
     """
 
     def __init__(
@@ -770,6 +771,7 @@ class SimpleHttpClient(BaseHttpClient):
         ip_allowlist: Optional[IPSet] = None,
         ip_blocklist: Optional[IPSet] = None,
         use_proxy: bool = False,
+        connection_pool: Optional[HTTPConnectionPool] = None,
     ):
         super().__init__(hs, treq_args=treq_args)
         self._ip_allowlist = ip_allowlist
@@ -782,22 +784,12 @@ class SimpleHttpClient(BaseHttpClient):
                 self.reactor, self._ip_allowlist, self._ip_blocklist
             )
 
-        # the pusher makes lots of concurrent SSL connections to Sygnal, and tends to
-        # do so in batches, so we need to allow the pool to keep lots of idle
-        # connections around.
-        pool = HTTPConnectionPool(self.reactor)
-        # XXX: The justification for using the cache factor here is that larger
-        # instances will need both more cache and more connections.
-        # Still, this should probably be a separate dial
-        pool.maxPersistentPerHost = max(int(100 * hs.config.caches.global_factor), 5)
-        pool.cachedConnectionTimeout = 2 * 60
-
         self.agent: IAgent = ProxyAgent(
             self.reactor,
             hs.get_reactor(),
             connectTimeout=15,
             contextFactory=self.hs.get_http_client_context_factory(),
-            pool=pool,
+            pool=connection_pool,
             use_proxy=use_proxy,
         )