element-hq / element-hq/synapse

Several write operations still occur on the main process when `/register` is routed to workers

Open
#13,379 0 comments 0 reactions 0 assignees View on GitHub
A-Registration A-Workers T-Enhancement
Dominant language
Python
Stars
4.6k
Forks
600
Avg merge
5d 22h
Merged PRs (30d)
51

Description

This issue has been migrated from [#13379](https://github.com/matrix-org/synapse/issues/13379).

---

It's possible to route [`POST /_matrix/client/v3/register`](https://spec.matrix.org/v1.3/client-server-api/#post_matrixclientv3register) to workers. This allows offloading most of the work involved in registration to the main process. A few operations occur on the main process ([here](https://github.com/matrix-org/synapse/blob/92103cb2c8b8bff6b522a7bfa8a3a776b4821b11/synapse/handlers/register.py#L683-L742) is where the logic splits between worker and main process):

https://github.com/matrix-org/synapse/blob/53b77b203ac12f20a6534393464588d5d49435f5/synapse/storage/databases/main/registration.py#L2103-L2191

I *think* the only operation in this method that can't currently be completed by a worker is: https://github.com/matrix-org/synapse/blob/53b77b203ac12f20a6534393464588d5d49435f5/synapse/storage/databases/main/registration.py#L2186-L2189

But the rest could potentially be delegated to the worker process.

I don't believe that these operations are particularly resource intensive.

Contributor guide

Open the contributing guide

Research direction

Start with the split in synapse/handlers/register.py at lines 683-742, then inspect synapse/storage/databases/main/registration.py lines 2103-2191. Identify which registration writes can be delegated to the worker while preserving the operation at lines 2186-2189 on the main process. Done means worker-routed /register no longer performs the delegable writes on the main process without changing registration behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, distributed-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.