From 700c8a0de5df7815949b8c792e8e471a91bb8721 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 17 Nov 2023 13:14:26 +0000 Subject: Reduce task concurrency (#16656) --- synapse/util/task_scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'synapse/util/task_scheduler.py') diff --git a/synapse/util/task_scheduler.py b/synapse/util/task_scheduler.py index 29c561e555..8c2df233d3 100644 --- a/synapse/util/task_scheduler.py +++ b/synapse/util/task_scheduler.py @@ -71,7 +71,7 @@ class TaskScheduler: # Time before a complete or failed task is deleted from the DB KEEP_TASKS_FOR_MS = 7 * 24 * 60 * 60 * 1000 # 1 week # Maximum number of tasks that can run at the same time - MAX_CONCURRENT_RUNNING_TASKS = 10 + MAX_CONCURRENT_RUNNING_TASKS = 5 # Time from the last task update after which we will log a warning LAST_UPDATE_BEFORE_WARNING_MS = 24 * 60 * 60 * 1000 # 24hrs -- cgit 1.5.1 From 6088303efb0f1498401718797941542089c2d432 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Fri, 17 Nov 2023 16:36:02 +0000 Subject: Speed up how quickly we launch new tasks (#16660) Now that we're reducing concurrency (#16656), this is more important. --- changelog.d/16660.misc | 1 + synapse/util/task_scheduler.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 changelog.d/16660.misc (limited to 'synapse/util/task_scheduler.py') diff --git a/changelog.d/16660.misc b/changelog.d/16660.misc new file mode 100644 index 0000000000..6763685b9d --- /dev/null +++ b/changelog.d/16660.misc @@ -0,0 +1 @@ +Reduce max concurrency of background tasks, reducing potential max DB load. diff --git a/synapse/util/task_scheduler.py b/synapse/util/task_scheduler.py index 8c2df233d3..b254d3f84c 100644 --- a/synapse/util/task_scheduler.py +++ b/synapse/util/task_scheduler.py @@ -377,7 +377,7 @@ class TaskScheduler: self._running_tasks.remove(task.id) # Try launch a new task since we've finished with this one. - self._clock.call_later(1, self._launch_scheduled_tasks) + self._clock.call_later(0.1, self._launch_scheduled_tasks) if len(self._running_tasks) >= TaskScheduler.MAX_CONCURRENT_RUNNING_TASKS: return -- cgit 1.5.1