summary refs log tree commit diff
path: root/synapse/http
diff options
context:
space:
mode:
authorSean Quah <8349537+squahtx@users.noreply.github.com>2023-05-03 13:09:20 +0100
committerGitHub <noreply@github.com>2023-05-03 13:09:20 +0100
commit3b837d856c4f867377d738eacb262cad28b14ad7 (patch)
tree8f401560a4c93b84a50ced5a5486c3fc930db852 /synapse/http
parentUpdate CHANGES.md (diff)
downloadsynapse-3b837d856c4f867377d738eacb262cad28b14ad7.tar.xz
Revert "Reduce the size of the HTTP connection pool for non-pushers" (#15530) v1.83.0rc1
#15514 introduced a regression where Synapse would encounter
`PartialDownloadError`s when fetching OpenID metadata for certain
providers on startup. Due to #8088, this prevents Synapse from starting
entirely.

Revert the change while we decide what to do about the regression.
Diffstat (limited to 'synapse/http')
-rw-r--r--synapse/http/client.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/http/client.py b/synapse/http/client.py
index 164abe9fc7..91fe474f36 100644
--- a/synapse/http/client.py
+++ b/synapse/http/client.py
@@ -768,7 +768,6 @@ class SimpleHttpClient(BaseHttpClient):
            request if it were otherwise caught in a blacklist.
         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__(
@@ -778,7 +777,6 @@ class SimpleHttpClient(BaseHttpClient):
         ip_whitelist: Optional[IPSet] = None,
         ip_blacklist: Optional[IPSet] = None,
         use_proxy: bool = False,
-        connection_pool: Optional[HTTPConnectionPool] = None,
     ):
         super().__init__(hs, treq_args=treq_args)
         self._ip_whitelist = ip_whitelist
@@ -791,12 +789,22 @@ class SimpleHttpClient(BaseHttpClient):
                 self.reactor, self._ip_whitelist, self._ip_blacklist
             )
 
+        # 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=connection_pool,
+            pool=pool,
             use_proxy=use_proxy,
         )