-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Move update_client_ips
to the background worker
#10425
Comments
I think all that needs to happen is wrapping the synapse/synapse/storage/databases/main/client_ips.py Lines 435 to 452 in c0df6ba
So something like: if hs.config.run_background_tasks:
self._client_ip_looper = self._clock.looping_call(
self._update_client_ips_batch, 5 * 1000
) as well as the other bits in the constructor. |
It doesn't look like #8500 has any info on why this wasn't done. I believe it was because You might be able to send those over replication, but that would be more invasive. |
@clokep does that imply that IP addresses are only noted in the database for the main process, not any workers? |
I think so but it has been a while since I looked at this. 😄 |
In addition, there's a simple optimisation we could make to the function to likely make it a bit lighter on the database. Currently we iterate over the list of all IP entries and make one or (more often) 2 separate queries against the database server. This results in both a high amount of DB and CPU usage. synapse/synapse/storage/databases/main/client_ips.py Lines 494 to 524 in c0df6ba
One simple solution we could do is to simply execute a single batch query against the server containing all modifications. We could:
|
synapse/synapse/storage/databases/main/client_ips.py
Lines 474 to 486 in c0df6ba
I have a feeling that we wanted to keep this on the main process as it needs to only be run by one, single process. However, this is no longer a concern now that we can dedicate all background work to a single worker through the
run_background_tasks_on: <worker_name>
config option.This operation has been reported as potentially CPU intensive on some deployments, so moving it off the main process would be a win.
(Also random thought: can this be converted to something that operates entirely in the database (postgres)?)
The text was updated successfully, but these errors were encountered: