From 0ca2857baab2d241a740a6ba5e8ed36d17756338 Mon Sep 17 00:00:00 2001 From: hera Date: Wed, 28 Feb 2018 00:35:03 +0000 Subject: [PATCH] increase sync cache to 2 minutes to give synchrotrons being hammered by repeating initial /syncs to get more chance to actually complete and avoid a DoS --- synapse/handlers/sync.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 1e8a50514b..8df66b0fcf 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -32,6 +32,7 @@ from six import itervalues, iteritems logger = logging.getLogger(__name__) +SYNC_RESPONSE_CACHE_MS = 2 * 60 * 1000 SyncConfig = collections.namedtuple("SyncConfig", [ "user", @@ -178,7 +179,9 @@ class SyncHandler(object): self.presence_handler = hs.get_presence_handler() self.event_sources = hs.get_event_sources() self.clock = hs.get_clock() - self.response_cache = ResponseCache(hs, "sync") + self.response_cache = ResponseCache( + hs, "sync", timeout_ms=SYNC_RESPONSE_CACHE_MS, + ) self.state = hs.get_state_handler() def wait_for_sync_for_user(self, sync_config, since_token=None, timeout=0,